Class SchemaCompatibility

java.lang.Object
org.apache.avro.SchemaCompatibility

public class SchemaCompatibility extends Object
Evaluate the compatibility between a reader schema and a writer schema. A reader and a writer schema are declared compatible if all datum instances of the writer schema can be successfully decoded using the specified reader schema.
  • Field Details

    • READER_WRITER_COMPATIBLE_MESSAGE

      public static final String READER_WRITER_COMPATIBLE_MESSAGE
      Message to annotate reader/writer schema pairs that are compatible.
      See Also:
  • Method Details

    • checkReaderWriterCompatibility

      public static SchemaCompatibility.SchemaPairCompatibility checkReaderWriterCompatibility(Schema reader, Schema writer)
      Validates that the provided reader schema can be used to decode avro data written with the provided writer schema.
      Parameters:
      reader - schema to check.
      writer - schema to check.
      Returns:
      a result object identifying any compatibility errors.
    • schemaNameEquals

      public static boolean schemaNameEquals(Schema reader, Schema writer)
      Tests the equality of two Avro named schemas.

      Matching includes reader name aliases.

      Parameters:
      reader - Named reader schema.
      writer - Named writer schema.
      Returns:
      whether the names of the named schemas match or not.
    • lookupWriterField

      public static Schema.Field lookupWriterField(Schema writerSchema, Schema.Field readerField)
      Identifies the writer field that corresponds to the specified reader field.

      Matching includes reader name aliases.

      Parameters:
      writerSchema - Schema of the record where to look for the writer field.
      readerField - Reader field to identify the corresponding writer field of.
      Returns:
      the writer field, if any does correspond, or None.