You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/11/16 13:01:00 UTC

[jira] [Commented] (NIFI-5662) AvroTypeUtil Decimal support using Fixed Error

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

ASF GitHub Bot commented on NIFI-5662:
--------------------------------------

GitHub user gideonkorir opened a pull request:

    https://github.com/apache/nifi/pull/3175

    Support for generic fixed when using decimal logical type

    Fix for [Avro decimal conversion](https://jira.apache.org/jira/browse/NIFI-5662)


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/gideonkorir/nifi nifi-5662

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/3175.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #3175
    
----
commit b52a3a240fcfbbec288deb37a0ef43acd79e42d2
Author: gkkorir <gk...@...>
Date:   2018-11-16T12:49:24Z

    Support for generic fixed when using decimal logical type

----


> AvroTypeUtil Decimal support using Fixed Error
> ----------------------------------------------
>
>                 Key: NIFI-5662
>                 URL: https://issues.apache.org/jira/browse/NIFI-5662
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Core Framework
>    Affects Versions: 1.7.1
>         Environment: RHEL 7.5
> JDK 1.8.182
>            Reporter: Gideon Korir
>            Priority: Major
>
> When the decimal is specified as fixed in the Avro schema, AvroTypeUtils converts the decimal into a ByteBuffer instead of a GenericFixed.
> The code:
> {code:java}
> return new Conversions.DecimalConversion().toBytes(decimal, fieldSchema, logicalType)
> {code}
>  Should be:
> {code:java}
> return fieldSchema.getType() == Type.BYTES
> ? new Conversions.DecimalConversion().toBytes(decimal, fieldSchema, logicalType)
> : new Conversions.DecimalConversion().toFixed(decimal, fieldSchema, logicalType);
> {code}
> The former causes the AvroRecordSetWriter to fail with the error: 
> _org.apache.avro.file.DataFileWriter$AppendWriteException: java.lang.ClassCastException: java.nio.HeapByteBuffer cannot be cast to org.apache.avro.generic.GenericFixed_



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)