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-1895) DeepCopy does not work with logical types
Date Wed, 31 Aug 2016 21:45:21 GMT

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

Doug Cutting commented on AVRO-1895:

I believe that it is an error to have the conversion for a logical type specified yet not
use that type for instances.  It shouldn't be an error to use a schema containing a logical
type when you have no conversion defined.  Then raw types should be used consistently.  But
if a conversion is defined, then values will be read into that type, assumed to be that type
when written, and thus deepCopy should also assume that they have the desired type.  Thus
I see no need to check that the type passed in matches that of the conversion.  If it does
not match then it will soon and correctly fail with a ClassCastException.  Does that sound
right to you?

> DeepCopy does not work with logical types
> -----------------------------------------
>                 Key: AVRO-1895
>                 URL: https://issues.apache.org/jira/browse/AVRO-1895
>             Project: Avro
>          Issue Type: Improvement
>          Components: logical types
>    Affects Versions: 1.8.1
>            Reporter: Taras Bobrovytsky
>            Assignee: Doug Cutting
>            Priority: Critical
>         Attachments: AVRO-1895.patch, AVRO-1895.patch, AVRO-1895.patch
> AvroSchema is taken from a compiled avsc file which contains a decimal field.
> {code}
> AvroSchema.Builder builder = AvroSchema.newBuilder();
> BigDecimal bd = new BigDecimal(new BigInteger("155"), 3);
> campaignBuilder.setDecimalField(bd);
> AvroSchema source = builder.build();
> //This line causes an exception
> AvroSchema.Builder builder1 = AvroSchema.newBuilder(source);
> {code}
> Exception:
> {code}
> InvocationTargetException: java.math.BigDecimal cannot be cast to java.nio.ByteBuffer
> {code}
> The same failure happens with GenericData as well:
> {code}
> GenericRecord copy = GenericData.get().deepCopy(AvroSchema.getClassSchema(), source);
> {code}

This message was sent by Atlassian JIRA

View raw message