Package org.apache.avro

# 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.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static final class`
`SchemaCompatibility.Incompatibility`
`static final class`
`SchemaCompatibility.SchemaCompatibilityResult`
Immutable class representing details about a particular schema pair compatibility check.
`static enum`
`SchemaCompatibility.SchemaCompatibilityType`
Identifies the type of a schema compatibility result.
`static enum`
`SchemaCompatibility.SchemaIncompatibilityType`
`static final class`
`SchemaCompatibility.SchemaPairCompatibility`
Provides information about the compatibility of a single reader and writer schema pair.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`READER_WRITER_COMPATIBLE_MESSAGE`
Message to annotate reader/writer schema pairs that are compatible.

## Method Summary

Modifier and Type
Method
Description
`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.
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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:
  - Constant Field Values

## 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.