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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • spec
    • None
    • Union resolution can fallback to a default value if the branch is not recognised by the reader.

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              teabot Elliot West
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: