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

Improve name and alias matching for named schemas



    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: java
    • Labels:


      When reading an avro file with a named schema, the aliases of the writers schema are not taken into account; only the aliases of the readers are matched against the writers name. Even if the writers aliases match the readers name, the schemas will not be matched.

      For example, the following two enum schemas will not be matched, even though they share a common alias.

      	"type"  : "enum",
      	"name"  : "foo",
      	"alias" : "CommonAlias",
      	"symbols" : ["LEFT", "RIGHT"]
      	"type"  : "enum",
      	"name"  : "bar",
      	"alias" : "CommonAlias",
      	"symbols" : ["LEFT", "RIGHT"]

      In most cases, the DatumReader resolves records of different names or namespaces by matching their fields.
      Unfortunately, there are some cases, where this sort of matching is not happening, but just the names are compared:

      • Other named nodes, like enums, fixed or fieldschemas are not matched this way.
      • A record inside a union is also only matched by the full name.

      The latter one is especially tricky, since two recordschemas that match structurally but differ in name or space, are interexchangable until they are put into an union, at which point an exception is thrown.

      I propose that two named schemas are matched, when they share a common name or alias.
      I implemented said changes and added a java annotation @AvroAlias(alias, space) that allows one to add an alias to a record, enum or field.


        1. AVRO-1347.patch
          8 kB
          Vincenz Priesnitz
        2. AVRO-1347.patch
          9 kB
          Vincenz Priesnitz

          Issue Links



              • Assignee:
                vince83 Vincenz Priesnitz
              • Votes:
                8 Vote for this issue
                9 Start watching this issue


                • Created: