title: Avro schema evolution
body: <p>I have two questions:</p>
  
  <ol>
  <li><p>Is it possible to use the same reader and parse records that were written with two schemas that are compatible, e.g. <code>Schema V2</code> only has an additional optional field compared to <code>Schema V1</code> and I want the reader to understand both? I think the answer here is no, but if yes, how do I do that?</p></li>
  <li><p>I have tried writing a record with <code>Schema V1</code> and reading it with <code>Schema V2</code>, but I get the following error:</p>
  
  <p>org.apache.avro.AvroTypeException: Found foo, expecting foo</p></li>
  </ol>
  
  <p>I used avro-1.7.3 and:</p>
  
  <pre><code>   writer = new GenericDatumWriter&lt;GenericData.Record&gt;(SchemaV1);
     reader = new GenericDatumReader&lt;GenericData.Record&gt;(SchemaV2, SchemaV1);
  </code></pre>
  
  <p>Here are examples of the two schemas (I have tried adding a namespace as well, but no luck). </p>
  
  <p>Schema V1:</p>
  
  <pre><code>{
  "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"
              }]
          }
      }
  }]
  }
  </code></pre>
  
  <p>Schema V2:</p>
  
  <pre><code>{
  "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"
                              }]
                      }
              }]
  }]
  } 
  </code></pre>
  
  <p>Thanks in advance.</p>