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

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


+
Jim Donofrio 2013-05-23, 14:51
+
Scott Carey 2013-05-23, 18:49
Copy link to this message
-
Re: why isnt there an option for a default enum so that the writer can add new enum symbols
I created AVRO-1340

On 05/23/2013 02:49 PM, Scott Carey wrote:
> I think this is simply a feature that has not been added.  It appears at
> quick glance to be a compatible specification change (it does not break
> old code or change the binary format).
>
> Please open a JIRA ticket explaining the use case and we can continue
> discussion there.
>
> On 5/23/13 7:51 AM, "Jim Donofrio" <[EMAIL PROTECTED]> wrote:
>
>> 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"]
>>              }
>>          }
>>      ]
>> }
>>
>
>