Grokbase Groups Avro user May 2013
FAQ
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"]
              }
          }
      ]
}

Search Discussions

  • Scott Carey at May 23, 2013 at 6:50 pm
    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" 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"]
    }
    }
    ]
    }
  • Jim Donofrio at May 25, 2013 at 5:36 am
    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" 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"]
    }
    }
    ]
    }

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesavro
postedMay 23, '13 at 2:52p
activeMay 25, '13 at 5:36a
posts3
users2
websiteavro.apache.org
irc#avro

2 users in discussion

Jim Donofrio: 2 posts Scott Carey: 1 post

People

Translate

site design / logo © 2021 Grokbase