avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Cutting (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1340) use default to allow old readers to specify default enum value when encountering new enum symbols
Date Fri, 10 Feb 2017 16:58:41 GMT

    [ https://issues.apache.org/jira/browse/AVRO-1340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15861536#comment-15861536

Doug Cutting commented on AVRO-1340:

Currently implementations can read data written by any other implementation, provided they
use the same schema.  For example, Java's GenericData can read any Avro data file, as can
other implementations that don't depend on generated code.

Schema evolution has limits.  Among these are that enums cannot easily evolve.  An attempt
to read data with an altered enum schema may currently fail.  We'd like to improve that here.
 But, in doing so, we should not make uses that don't require schema evolution fail.  Changing
the syntax of enums as you proposed would make that schema unparseable by existing implementations.

The syntax that Matthieu suggested above is compatible and I believe semantically equivalent
to your proposal.  Or, instead of a list of aliases, one might designate an extra symbol to
be used when an unknown symbol is encountered, e.g.:{code}
  “type”: “enum”,
  “name”: “Suit”,
  “symbols”: [“UNKNOWN”, "CLUBS", "HEARTS", “SPADES”, “DIAMONDS”],
  “extra”:  “UNKNOWN”

> use default to allow old readers to specify default enum value when encountering new
enum symbols
> -------------------------------------------------------------------------------------------------
>                 Key: AVRO-1340
>                 URL: https://issues.apache.org/jira/browse/AVRO-1340
>             Project: Avro
>          Issue Type: Improvement
>          Components: spec
>         Environment: N/A
>            Reporter: Jim Donofrio
>            Priority: Minor
> 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.
> This makes it difficult to use enum's because you can never add a enum value and keep
old reader's compatible. Why not use the default option to refer to one of enum values so
that when a old reader encounters a enum ordinal it does not recognize, it can default to
the optional schema provided one. If the old schema does not provide a default then the older
reader can continue to fail as it does today.

This message was sent by Atlassian JIRA

View raw message