[
https://issues.apache.org/jira/browse/AVRO-1761?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15047566#comment-15047566
]
Ryan Blue commented on AVRO-1761:
---------------------------------
Rafael, the way this usually works is that your read schema reflects what you
expect to get back and aliases are resolved internally to provide the expected
fields. So if you have a record with field "foo" that you've renamed to "bar"
then your read schema lists "foo" as an alias for "bar" and all records that
are read will contain a "bar" field whether the value came from a file with
"foo" or a file with "bar".
It sounds like you're hitting the situation where you are getting some records
with "foo" and some with "bar" depending on the file they came from. I'm
guessing that this is happening because you aren't supplying a read schema.
Read schemas are the right way to tell Avro what you expect the records to look
like and would probably solve your problem here.
> Accessing a field by alias name on a GenericRecord
> --------------------------------------------------
>
> Key: AVRO-1761
> URL: https://issues.apache.org/jira/browse/AVRO-1761
> Project: Avro
> Issue Type: Improvement
> Reporter: Rafael Chacon
>
> Hi all -
> We noticed that accessing a field by an alias name on a GenericRecord
> (https://avro.apache.org/docs/1.7.6/api/java/org/apache/avro/generic/GenericRecord.html)
> doesn't work on the current implementation of the Avro java package.
> Is this intended by design? We have some use cases where this is really
> useful and we were wondering if this something we could add to the avro
> package.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)