Michael Overmeyer created AVRO-1817:
---------------------------------------

             Summary: 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 value.

For example, Colour.RED => "RED", Colour.YELLOW => "YELLOW", Colour.GREEN => 
"GREEN"



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to