avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexandre Normand (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1153) Exception when trying to write object with Nullable field that is of Stringable type
Date Wed, 12 Sep 2012 18:31:08 GMT

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

Alexandre Normand commented on AVRO-1153:
-----------------------------------------

I do need to serialize maps with Integer keys but extending the reflection to do that seems
fair. 

I'll revert to my initial patch which was more like you had suggested in your earlier comment
while also doing the refactoring to add the isStringable method. 
                
> Exception when trying to write object with Nullable field that is of Stringable type
> ------------------------------------------------------------------------------------
>
>                 Key: AVRO-1153
>                 URL: https://issues.apache.org/jira/browse/AVRO-1153
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Alexandre Normand
>            Assignee: Alexandre Normand
>              Labels: newbie, reflection
>         Attachments: AVRO-1153.patch, AVRO-1153.patch, AVRO-1153.patch
>
>
> There seems to be an issue with [stringable fields|https://issues.apache.org/jira/browse/AVRO-1146]
that are nullable. I'm mostly using ReflectData.AllowNull in my real usage of this feature
and I'm seeing it fail with this:
> {code}
> org.apache.avro.AvroRuntimeException: Unknown datum type: 10
> 	at org.apache.avro.generic.GenericData.getSchemaName(GenericData.java:574)
> 	at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:539)
> 	at org.apache.avro.generic.GenericDatumWriter.resolveUnion(GenericDatumWriter.java:137)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:70)
> 	at org.apache.avro.reflect.ReflectDatumWriter.write(ReflectDatumWriter.java:104)
> 	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
> 	at org.apache.avro.reflect.ReflectDatumWriter.write(ReflectDatumWriter.java:104)
> 	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:57)
> {code}
> Here's a quick test that shows this problem:
> {code}
> public static class N1 {
>       BigDecimal number;
>   }
>   @Test public void testNullableStringableField() throws Exception {
>       N1 datum = new N1();
>       datum.number = BigDecimal.TEN;
>       checkBinary(ReflectData.AllowNull.get(), ReflectData.AllowNull.get().getSchema(N1.class),
datum, false);
>   }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message