Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.9.2
-
None
-
None
Description
When evolving an avro scheme I think it should be possible to merge multiple records in to one.
So with this union as writer type:
[ { "type" : "record", "name" : "A", "fields" : [ { "name" : "a", "type" : "boolean" } ] }, { "type" : "record", "name" : "B", "fields" : [ { "name" : "b", "type" : "boolean" } ] } ]
I want to ready it with the following reader schema:
[ { "type" : "record", "name" : "B", "aliases" : [ "A" ], "fields" : [ { "name" : "a", "type" : "boolean", "default" : true}, { "name" : "b", "type" : "boolean", "default" : true} ] } ]
This however generates the following stacktrace when trying to read it:
org.apache.avro.AvroRuntimeException: Duplicate in union:B at org.apache.avro.Schema$UnionSchema.<init>(Schema.java:1165) at org.apache.avro.Schema.createUnion(Schema.java:224) at org.apache.avro.Schema.applyAliases(Schema.java:1846) at org.apache.avro.Schema.applyAliases(Schema.java:1802) at org.apache.avro.Resolver.resolve(Resolver.java:62) at org.apache.avro.Resolver.resolve(Resolver.java:69) at org.apache.avro.io.parsing.ResolvingGrammarGenerator.generate(ResolvingGrammarGenerator.java:64) at org.apache.avro.io.ResolvingDecoder.resolve(ResolvingDecoder.java:84)
We have a pull request coming up to fix this issue.