Package org.apache.avro
Class SchemaCompatibility
java.lang.Object
org.apache.avro.SchemaCompatibility
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
static final class
Immutable class representing details about a particular schema pair compatibility check.static enum
Identifies the type of a schema compatibility result.static enum
static final class
Provides information about the compatibility of a single reader and writer schema pair. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Message to annotate reader/writer schema pairs that are compatible. -
Method Summary
Modifier and TypeMethodDescriptioncheckReaderWriterCompatibility
(Schema reader, Schema writer) Validates that the provided reader schema can be used to decode avro data written with the provided writer schema.static Schema.Field
lookupWriterField
(Schema writerSchema, Schema.Field readerField) Identifies the writer field that corresponds to the specified reader field.static boolean
schemaNameEquals
(Schema reader, Schema writer) Tests the equality of two Avro named schemas.
-
Field Details
-
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
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
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.
-