Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # user >> Does extending union break compatibility


Copy link to this message
-
Re: Does extending union break compatibility

On 11/3/11 4:56 PM, "Neil Davudo" <[EMAIL PROTECTED]> wrote:

>I have a record defined as follows
>
>// version 1
>record SomeRecord
>{
>    union { null, TypeA } unionOfTypes;
>}
>
>I change the record to the following
>
>// version 2
>record SomeRecord
>{
>    union { null, TypeA, TypeB } unionOfTypes;
>}
>
>Does the change break compatibility? Would data encoded using version 1
>of the record definition be decodable using version 2 of the record
>definition?

Readers with the second schema should be able to read data written with
the first schema, provided they use the API properly (both schemas must be
provided to the reader, so that it can translate from one to the other).

The reverse, reading data written in the latter schema with the first
schema, is possible as well provided that the first schema contains a
default value so that if the reader encounters a union branch it does not
know about, it can substitute the default value.
>
>TIA
>
>Neil