[
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.
(sorry about the formatting, I just can't get it right for some reason)
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.
(sorry about the formatting, I just can't get it right for some reason)
> 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.
>
> (sorry about the formatting, I just can't get it right for some reason)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)