Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-5662

AvroTypeUtil Decimal support using Fixed Error

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.7.1
    • 1.9.0
    • Core Framework
    • None
    • RHEL 7.5
      JDK 1.8.182

    Description

      When the decimal is specified as fixed in the Avro schema, AvroTypeUtils converts the decimal into a ByteBuffer instead of a GenericFixed.

      The code:

      return new Conversions.DecimalConversion().toBytes(decimal, fieldSchema, logicalType)
      

       Should be:

      return fieldSchema.getType() == Type.BYTES
      ? new Conversions.DecimalConversion().toBytes(decimal, fieldSchema, logicalType)
      : new Conversions.DecimalConversion().toFixed(decimal, fieldSchema, logicalType);
      

      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

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              korir Gideon Korir
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: