Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2830

Union with aliases fail on 'Duplicate in union'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.9.2
    • None
    • java
    • 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.

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            steven.aerts Steven Aerts
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: