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

Use default to allow old readers to specify default union value when encountering new union branches

Add voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments


    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: spec
    • Labels:
    • Release Note:
      Union resolution can fallback to a default value if the branch is not recognised by the reader.


      The schema resolution page says:

      if both are unions:
      The first schema in the reader's union that matches the selected writer's union schema is recursively resolved against it. if none match, an error is signalled.

      This makes it difficult to use unions because you can never add a new type to a union and keep old reader's compatible. Can we not follow the approach provided by other Avro extensible types (record, enum) and use a default value so that when an old reader encounters a union branch it does not recognise, it can default to the optional schema provided one. If the old schema does not provide a default then the older reader can continue to fail as it does today.

      Clearly, the provided default value must be valid with respect to one of the types declared in the reader's union schema.


        Issue Links



            • Assignee:
              teabot Elliot West


              • Created:

                Issue deployment