Avro Field Order matters when evolving a schema
JSON and AVRO are both great serialization models. JSON is all text, human readable, and very verbose. AVRO is an efficient binary format. They can serialize the same data but they can also handle schema evolution or field changes differently
JSON supports field order changes because all of its fields come with their own label in every single message. Avro messages do not always handle field order changes.
JSON and AVRO are both great serialization models. JSON is all text, human readable, and very verbose. AVRO is an efficient binary format. They can serialize the same data but they can also handle schema evolution or field changes differently
Field Order
Avro serializer/deserializers operate on fields in the order they are declared. Producers and Consumers must be on a compatible schema including the field order. Do not change the order of AVRO fields. All Producers and Consumers are must be updated at the same time if you change the field order.
The AVRO 1.8 documentation says
Records
A record is encoded by encoding the values of its fields in the order that they are declared. In other words, a record is encoded as just the concatenation of the encodings of its fields. Field values are encoded per their schema.
and
Enums
An enum is encoded by a int, representing the zero-based position of the symbol in the schema.
Schema Compatability
Confluent documentation
Compatibility Type | Changes allowed | Check against which schemas | Upgrade first |
---|---|---|---|
BACKWARD |
| Last version | Consumers |
BACKWARD_TRANSITIVE |
| All previous versions | Consumers |
FORWARD |
| Last version | Producers |
FORWARD_TRANSITIVE |
| All previous versions | Producers |
FULL |
| Last version | Any order |
FULL_TRANSITIVE |
| All previous versions | Any order |
NONE |
| Compatibility checking disabled | Depends |
Comments
Post a Comment