You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Michael Overmeyer (JIRA)" <ji...@apache.org> on 2016/03/31 14:37:25 UTC
[jira] [Updated] (AVRO-1817) Allow enums to be "promoted" to
strings
[ https://issues.apache.org/jira/browse/AVRO-1817?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Overmeyer updated AVRO-1817:
------------------------------------
Description:
We should consider adding a resolution rule that can promote an enum to a string using the enum's symbol.
I have an Avro schema that has a field with an enum type. However, I have realized that an enum is not the type I actually wanted. I would much rather have the type of the field be a string. I went to change this, but of course this type of change (enum -> string) is not within the bounds of Avro's schema evolution. Therefore a reader with this changed schema is not be able to read an object written with the old schema.
For example, if the writer schema was:
enum Colour {
RED, YELLOW, GREEN
}
protocol stoplight {
Colour colour;
}
And the reader schema was:
protocol stoplight {
string colour;
}
Then when you access the colour field of your object, you get the string representation of the enum value's symbol .
For example, Colour.RED => "RED", Colour.YELLOW => "YELLOW", Colour.GREEN => "GREEN"
was:
We should consider adding a resolution rule that can promote an enum to a string using the enum's symbol.
I have an Avro schema that has a field with an enum type. However, I have realized that an enum is not the type I actually wanted. I would much rather have the type of the field be a string. I went to change this, but of course this type of change (enum -> string) is not within the bounds of Avro's schema evolution. Therefore a reader with this changed schema is not be able to read an object written with the old schema.
For example, if the writer schema was:
enum Colour {
RED, YELLOW, GREEN
}
protocol stoplight {
Colour colour;
}
And the reader schema was:
protocol stoplight {
string colour;
}
Then when you access the colour field of your object, you get the string value.
For example, Colour.RED => "RED", Colour.YELLOW => "YELLOW", Colour.GREEN => "GREEN"
> Allow enums to be "promoted" to strings
> ---------------------------------------
>
> Key: AVRO-1817
> URL: https://issues.apache.org/jira/browse/AVRO-1817
> Project: Avro
> Issue Type: Improvement
> Reporter: Michael Overmeyer
> Priority: Minor
>
> We should consider adding a resolution rule that can promote an enum to a string using the enum's symbol.
> I have an Avro schema that has a field with an enum type. However, I have realized that an enum is not the type I actually wanted. I would much rather have the type of the field be a string. I went to change this, but of course this type of change (enum -> string) is not within the bounds of Avro's schema evolution. Therefore a reader with this changed schema is not be able to read an object written with the old schema.
> For example, if the writer schema was:
> enum Colour {
> RED, YELLOW, GREEN
> }
> protocol stoplight {
> Colour colour;
> }
> And the reader schema was:
> protocol stoplight {
> string colour;
> }
> Then when you access the colour field of your object, you get the string representation of the enum value's symbol .
> For example, Colour.RED => "RED", Colour.YELLOW => "YELLOW", Colour.GREEN => "GREEN"
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)