Avro schema evolution
avro
Solution
I encountered the same issue. That might be a bug of avro, but you probably can work around by adding "default": null to the field of "purchase".
Check my blog for details: http://ben-tech.blogspot.com/2013/05/avro-schema-evolution.html
Problem
I have two questions: Is it possible to use the same reader and parse records that were written with two schemas that are compatible, e.g. `Schema V2` only has an additional optional field compared to `Schema V1` and I want the reader to understand both? I think the answer here is no, but if yes, how do I do that? I have tried writing a record with `Schema V1` and reading it with `Schema V2`, but I get the following error: org.apache.avro.AvroTypeException: Found foo, expecting foo I used avro-1.7.3 and: ``` writer = new GenericDatumWriter<GenericData.Record>(SchemaV1); reader = new GenericDatumReader<GenericData.Record>(SchemaV2, SchemaV1); ``` Here are examples of the two schemas (I have tried adding a namespace as well, but no luck). Schema V1: ``` { "name": "foo", "type": "record", "fields": [{ "name": "products", "type": { "type": "array", "items": { "name": "product", "type": "record", "fields": [{ "name": "a1", "type": "string" }, { "name": "a2", "type": {"type": "fixed", "name": "a3", "size": 1} }, { "name": "a4", "type": "int" }, { "name": "a5", "type": "int" }] } } }] } ``` Schema V2: ``` { "name": "foo", "type": "record", "fields": [{ "name": "products", "type": { "type": "array", "items": { "name": "product", "type": "record", "fields": [{ "name": "a1", "type": "string" }, { "name": "a2", "type": {"type": "fixed", "name": "a3", "size": 1} }, { "name": "a4", "type": "int" }, { "name": "a5", "type": "int" }] } } }, { "name": "purchases", "type": ["null",{ "type": "array", "items": { "name": "purchase", "type": "record", "fields": [{ "name": "a1", "type": "int" }, { "name": "a2", "type": "int" }] } }] }] } ``` Thanks in advance.