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

Switch to Plain View
Avro, mail # dev - Avro enum and passivity.


Copy link to this message
-
Avro enum and passivity.
Koduri,Vinay 2013-07-15, 22:11
Apache avro schema resolution throws an error, when deserializing, if the writer's enum  symbol is not present in the reader's enum definition[1]. To illustrate with example consider the following enum that is shared by the writer and the reader.

Version1:
protocol SampleProtocol {
          enum Suit{
                    SPADES, HEARTS, CLUBS
          }
    record Card {
        Suit suit;
    }
}
Now if the writer  adds a new value "DIAMONDS" to the Suit enum and serializes a datum with the "DIAMONDS"

Version2:
protocol SampleProtocol {
          enum Suit{
                    SPADES, HEARTS, CLUBS, DIAMONDS
          }
    record Card {
        Suit suit;
    }
}
Now Reader,when deserializing with version 1 of the schema, will thrown an error  as it does not understand "DIAMONDS". This forces the reader and the writer enum definitions to be sync.

As this is a non passive change whenever a enum gets updated, I am curios why this was designed to be non-passive, rather than simply ignoring the new value or giving a "special" unsupported enum value if the enum is required.

CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
+
Doug Cutting 2013-07-16, 00:01
+
Koduri,Vinay 2013-07-16, 01:26
+
Doug Cutting 2013-07-16, 18:09