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

Switch to Threaded View
Avro >> mail # user >> why isnt there an option for a default enum so that the writer can add new enum symbols


Copy link to this message
-
why isnt there an option for a default enum so that the writer can add new enum symbols
The schema resolution page says:

 > if both are enums:
 > if the writer's symbol is not present in the reader's enum, then an
error is signalled.

Is there a reason you could not allow us to provide one of the symbols
as a default in the reader so that when the reader read the enum with
symbol it didnt have, that new symbol would get defaulted to the default
symbol we provide?

For example with the below schema's this would currently fail if the old
reader encountered a Enum1.C in the data. Why not provide users the
option to set "default": "A" for example so that any unknown enum's are
bined into one? The user might have an unknown enum or something.
Currently I was going to implement this in my application by just using
an int type and looking up the ordinal of my own Java Enum. If the int
is larger than any of the oridinals, the enum would be set to my own
default value in the enum.

Thanks.

Original schema:

{
     "type": "record",
     "name": "EnumExample",
     "fields": [
         {
             "name": "enum1",
             "type": {
                 "type": "enum",
                 "name": "Enum1",
                 "symbols": ["A", "B"]
             }
         }
     ]
}

New schema:

{
     "type": "record",
     "name": "EnumExample",
     "fields": [
         {
             "name": "enum1",
             "type": {
                 "type": "enum",
                 "name": "Enum1",
                 "symbols": ["A", "B", "C"]
             }
         }
     ]
}