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

Switch to Threaded View
Avro >> mail # user >> Explicit Values for Enums


Copy link to this message
-
Explicit Values for Enums
I did a few searches on Jira and couldn't find anything it, so apologies if
this has been requested previously.

It seems like it would be useful to allow an explicit value for enumeration
members. I suppose the biggest argument against it would be that might have
to be a breaking change to the schemas, since the current list of values is
just an array of strings, but maybe it could be added as an optional schema
field which would override the implicit sequential numbering.

// Maybe?
{
     "type": "enum",
     "name": "Roles",
     "symbols": [ "Producer", "Consumer" ]
     "values": [ 100, 101 ]
}

// This is just too ugly
{
     "type": "enum",
     "name": "Roles",
     "symbols": [ "Producer=100", "Consumer=101" ]
}

// Alternating strings and values? still pretty ugly.
{
     "type": "enum",
     "name": "Roles",
     "symbols": [ "Producer", 100,  "Consumer", 101 ]
}

~Bill