avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Cutting (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AVRO-759) Field alias not working due to Schema.getFieldAlias return null for fields not aliased
Date Tue, 08 Feb 2011 23:38:57 GMT

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

Doug Cutting commented on AVRO-759:
-----------------------------------

I am unable to duplicate this.  Can you please provide a test that illustrates the NullPointerException?

> Field alias not working due to Schema.getFieldAlias return null for fields not aliased
> --------------------------------------------------------------------------------------
>
>                 Key: AVRO-759
>                 URL: https://issues.apache.org/jira/browse/AVRO-759
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.4.1
>            Reporter: Xiaolu Ye
>
> When field alias is used, I get NullPointerException in Schema.Field.hashCode() because
Field.name is null. This is because Schema.getFieldAlias return null for non-aliased field.
Currently the code is as below:
> private static String getFieldAlias(Name record, String field,
>         Map<Name, Map<String, String>> fieldAliases) {
>         Map<String, String> recordAliases = fieldAliases.get(record);
>         if(recordAliases == null) {
>             return field;
>         }
>         return recordAliases.get(field);
> }
> Given recordAliases only has aliases, it should return field itself if it's not in recordAliases
as below:
> private static String getFieldAlias(Name record, String field,
>         Map<Name, Map<String, String>> fieldAliases) {
>         Map<String, String> recordAliases = fieldAliases.get(record);
>         if(recordAliases == null) {
>             return field;
>         }
>         String ret = recordAliases.get(field);
>         if (ret == null) ret = field;
>         return ret;
> }

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message