Skip to content

Add support for deduplicating definitions in schemas#202

Closed
travisbrown wants to merge 1 commit intoflavray:mainfrom
travisbrown:topic/dedup-defs
Closed

Add support for deduplicating definitions in schemas#202
travisbrown wants to merge 1 commit intoflavray:mainfrom
travisbrown:topic/dedup-defs

Conversation

@travisbrown
Copy link

This is a sketch of an approach that could be used to fix #182.

The problem is that the library replaces every name reference in a schema with the full definition, and the Avro tooling for Java (and possibly other platforms) considers these "redefinitions" and fails when it sees them.

I think there are two ways to fix this:

  1. Add a reference variant to the schema ADT and bundle a map from references to definitions with the schema type.
  2. Deduplicate definitions during serialization.

This PR does the latter, which is much less invasive. When the schema is being written to the Avro file, it only writes the first definition for each record type, and replaces the rest with the full name.

This PR is a quick sketch that is currently untested and only handles records (not enums or fixeds), since I just wanted to make sure it solves the problem in my case (at first glance it seems to) and to check whether a change like this would be considered.

@martin-g
Copy link

martin-g commented Mar 5, 2022

@travisbrown You might want to read this - #99 (comment)

@travisbrown
Copy link
Author

@martin-g Ah, thanks. I saw the general status change but not that specific fix. I'll take a closer look.

@travisbrown travisbrown closed this Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

org.apache.avro.SchemaParseException: Can't redefine: test

2 participants