Omer van Kloeten created AVRO-3988:
--------------------------------------

             Summary: Allow enum value aliasing
                 Key: AVRO-3988
                 URL: https://issues.apache.org/jira/browse/AVRO-3988
             Project: Apache Avro
          Issue Type: Improvement
            Reporter: Omer van Kloeten


When providing an enum in a schema, it's an incompatible change to rename any 
of its values. However, Avro can offer compatibility using aliases.

Let's take the example from the docs:

{{{}}
{{  "type": "enum",}}
{{  "name": "Suit",}}
{{  "symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]}}
{{}}}

I want to change the name "CLUBS" to "CLOVERS". I can do that using the syntax:

{{{}}
{{  "type": "enum",}}
{{  "name": "Suit",}}
{{  "symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLOVERS"],}}
{{  "aliases": {}}
{{    "CLOVERS": [ "CLUBS" ]}}
{{  }}}
{{}}}

This change of name can be accommodated by the reader schema.

Another thing this opens up is the ability to consolidate values. For instance, 
again based on the example schema (first one in this ticket):

{{{}}
{{  "type": "enum",}}
{{  "name": "Suit",}}
{{  "symbols" : ["SPADES", "HEARTS", "CLOVERS"],}}
{{  "aliases": {}}
{{{}    "{}}}{{{}SPADES{}}}{{{}": [ "{}}}{{{}DIAMONDS{}}}{{{}" ]{}}}
{{  }}}
{{}}}

The above says that any DIAMONDS should be converted by the reader schema to 
SPADES.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to