You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "Omer van Kloeten (Jira)" <ji...@apache.org> on 2024/05/29 10:59:00 UTC

[jira] [Updated] (AVRO-3988) Allow enum value aliasing

     [ https://issues.apache.org/jira/browse/AVRO-3988?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Omer van Kloeten updated AVRO-3988:
-----------------------------------
    Description: 
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.

  was:
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.


> 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
>            Priority: Minor
>
> 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)