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

Felix GV commented on AVRO-1340:
--------------------------------

I don’t get what is the use case served by having a field default as well as an 
enum default. I am looking at the “Default and Fallback” tab in the google 
spreadsheet, and I am confused at the inconsistent outcomes.

I am left wondering: “wouldn’t it be simpler if it was illegal to define a 
schema with a different field default and enum default?” ... in which case, of 
course, if it was illegal to make them different, then there is probably no 
point in having both.

This is why I kept pushing for a quick 30 second description of what the 
proposed semantic is. Doing the implementation first and retrofitting the 
explanation backwards to match it seems like a roundabout and inefficient way 
of designing an API.

Currently, my recommendation to my users is this: “Do not use Avro enums as 
they are a broken un-evolvable part of the specification. If you need enum-like 
semantics, then define an int field and map it manually to an enum in your Java 
code.”

Now, with this proposed implementation, I honestly wonder whether it is simpler 
to maintain exactly the same narrative (“avro enums are broken so you should 
use an int instead”) or to tell my users “avro enums are broken unless you 
specify the same value in the enum default and field dedault” or if it’s worth 
trying to explain the full matrix of possibilities.

Although I feel like API semantics should be crystal clear enough to stand on 
their own in abstract terms, it does help sometimes to provide an explanation 
by way of an example. Can you provide one such example where the intricacy of 
this API serves a useful purpose?

> 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