[ 
https://issues.apache.org/jira/browse/AVRO-1340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16331144#comment-16331144
 ] 

Adam Bellemare commented on AVRO-1340:
--------------------------------------

I don't know how much clarity this will add, but I have tried to map out the 
two processes described above as best I can
 # field-default and enum-default(fallback)
 # field-default only

[https://docs.google.com/spreadsheets/d/1YkTBnHCBPGz2t0gQI3OioKS_xP9h9lq_a-gS2jSGFAc/edit?usp=sharing]

It seems that this process works best with #1. It gives us both the ability to 
set an "UNKNOWN" value at the enum level, but to also allow individual readers 
of the data to determine their own defaults for system usage. Also, we can do 
handle different behaviour between missing enum values (not set by writer) and 
evolved or possible incorrect values. This way our consumer schema will look 
like:

 
{code:java}
"fields" : [ {
  "name" : "foo",
  "type" : {
    "type" : "enum",
    "name" : "Bar",
    "symbols" : [ "A", "B", "FieldDefault", "EnumDefault"],
    "default" : "EnumDefault"
  },
  "default" : "FieldDefault"
}]
{code}
I would expect the enum value resolution to follow this order:
 # If a field-default value is set, it must exist in the enum symbols. 
enum-default is also required to be in the symbols.
 # Reader field-default is applied if the value is not set by the writer
 # Reader enum-default (aka: fallback) is applied if the input symbol does not 
match any values in the reader enum symbols.

My understanding is that the field-default must be applied before the 
enum-default to preserve existing functionality. We have to apply the field 
default for unset values before we can override it with a fallback symbol.

Is my understanding of this correct?

> use default to allow old readers to specify default enum value when 
> encountering new enum symbols
> -------------------------------------------------------------------------------------------------
>
>                 Key: AVRO-1340
>                 URL: https://issues.apache.org/jira/browse/AVRO-1340
>             Project: Avro
>          Issue Type: Improvement
>          Components: spec
>         Environment: N/A
>            Reporter: Jim Donofrio
>            Priority: Minor
>
> The schema resolution page says:
> > if both are enums:
> > if the writer's symbol is not present in the reader's enum, then an
> error is signalled.
> This makes it difficult to use enum's because you can never add a enum value 
> and keep old reader's compatible. Why not use the default option to refer to 
> one of enum values so that when a old reader encounters a enum ordinal it 
> does not recognize, it can default to the optional schema provided one. If 
> the old schema does not provide a default then the older reader can continue 
> to fail as it does today.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to