06: Avro Schema evolution tutorial

Q1. What do you understand by the term “AVRO schema evolution“?
A1. Schema evolution is the term used for how the store behaves when Avro schema is changed after data has been written to the store using an older version of that schema.

Q2. When does the schema evolution take place?
A2. During deserialization. In other words, when reading an avro file that was written with an older schema, and you can read it with a newer (i.e. evolved) schema provided you have defined the default values in your schema.

employee-ver1.avsc

employee-ver2.avsc

The schema has evolved with an additional field named “salary”. It defines a “default” as “null”.

Java code to write/read to/from sequence file

It initially rites and reads with “employee-ver1.avsc”, and then with evolved schema “employee-ver2.avsc”.

Output

Q3. What schema modifications can you safely perform?
A3.

1) A field with a default value is added, and a field that was previously defined with a default value is removed.

2) A field’s doc or order attribute is changed, added or removed.

3) A field’s default value is added, or changed.

4) Field or type aliases are added, or removed.

5) A non-union type may be changed to a union that contains only the original type, or vice-versa.


300+ Java Interview FAQs

800+ Java Interview Q&As

Top