You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Alexandre Normand (JIRA)" <ji...@apache.org> on 2012/09/12 19:48:07 UTC

[jira] [Commented] (AVRO-1153) Exception when trying to write object with Nullable field that is of Stringable type

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

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

What you're suggesting was actually what I had in my first version. The problem with that though is that if I add Integer.class to stringables, then this code becomes flawed because this would return the String type when it should actually be an Integer. Now, why would I need to add Integer.class to stringables? To allow Integer Map keys, that's why. 

Maybe this is a good argument for splitting plain stringables from map keys stringables. What do you think?
                
> 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