Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # dev >> Schema Resolution for Enums


Copy link to this message
-
Schema Resolution for Enums
Hello,

According to Avro Standard 1.7.5 enums match when names match and all writer symbols exist in reader schema.

According to this definition the following writer schema:
  { "type": "enum", "name":"Suit","symbols":["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]}
matches this reader schema:
  { "type": "enum", "name":"Suit","symbols":["HEARTS", "SPADES", "DIAMONDS", "CLUBS"]}

However this can lead to semantical problems. Assume I have the following datum:
  Suit suit = SPADES

According to writer schema a zero will be encoded. However when deserialized using the aforementioned reader schema the datum will correspond to HEARTS since the order of symbols has changed in the reader schema and HEARTS is the first.

My question is, why the standard doesn't explicitly add another constraint for matching enums like the order of elements must be preserved, or is it implied?

Best regards,
Youssef Hatem
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB