[
https://issues.apache.org/jira/browse/AVRO-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13452576#comment-13452576
]
Alexandre Normand commented on AVRO-1146:
-----------------------------------------
There seems to be an issue with stringable fields 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)
{code}
I'm going to try and look at it this evening but, meanwhile, 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}
> Can't use ReflectData to get schema when the type has a BigDecimal or
> BigInteger field
> --------------------------------------------------------------------------------------
>
> Key: AVRO-1146
> URL: https://issues.apache.org/jira/browse/AVRO-1146
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.7.0
> Reporter: Alexandre Normand
> Assignee: Alexandre Normand
> Labels: newbie
> Fix For: 1.7.2
>
> Attachments: AVRO-1146.java, AVRO-1146.patch, AVRO-1146.patch,
> TestReflectDataWithBigDecimal.java
>
>
> I'm using avro Reflection API for a specific use case and I have a bug where
> if the object I'm trying to get the Schema for has a field of type
> BigDecimal. Because BigDecimal extends java.lang.Number, we try to create a
> primitive schema for it but fail doing so with the following error:
> *{{org.apache.avro.AvroRuntimeException: Not a Specific class: class
> java.math.BigDecimal}}*
> I'm attaching a unit test that shows the problem with a basic type that has a
> single BigDecimal field.
> This basically also applied to all subclasses of java.lang.Number that are
> not primitives.
--
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