[
https://issues.apache.org/jira/browse/AVRO-75?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12797869#action_12797869
]
Philip Zeyliger commented on AVRO-75:
-------------------------------------
I was under the impression that you were not allowed to read the schema
record(a=string) with the schema record(b=string), i.e., that this would throw
an exception when the schemas were being reconciled. If the reader wanted to
be open to unset fields, he could explicitly read with
record(b=union(null,string)) or record(b=string(default="foo")).
I think failing fast here is good behavior. If you're using a schema
record(b=string), then you expect to be able to use record.b without checking,
first, that b is not null. In the RPC case especially, if some rogue-ish
client (one that was too old, or had a typo) came by, my server would simply
throw NPE, instead of usefully telling me where the schema went wrong.
For types where null is not an option (int), you'd see even more specific
behavior (because int would default, presumably, to 0). If we have so much
type information, I'd rather not ask the user to check isSet(field_name) before
every usage.
> Clarify resolution for enums (and fix code)
> -------------------------------------------
>
> Key: AVRO-75
> URL: https://issues.apache.org/jira/browse/AVRO-75
> Project: Avro
> Issue Type: Bug
> Components: spec
> Reporter: Raymie Stata
> Assignee: Doug Cutting
> Fix For: 1.3.0
>
>
> The current resolution rule for enum's says: "if the writer's symbol is not
> present in the reader's enum, then the enum value is unset." This is the
> only place the word "unset" is used in the doc, it's not clear what you mean.
> The code seems to be inconsistent: GenericDatumReader will happily return a
> symbol the reader doesn't understand; ReflectDatumReader will probably throw
> a class-not-found exception; ResolvingDecoder throws an error.
> I propose that we declare this case an error, i.e., rewrite the spec to "if
> the writer's symbol is not listed in the reader's enum, an error is
> signaled." GenericDatumReader should be updated to throw an error in this
> case.
> If we decide to stick with the "unset" language, we need to define what
> "unset" means (and, if necessary, update ReflectDatumReader and
> ResolvingDecoder).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.