Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-3536

Union type not inheriting type conversions

    XMLWordPrintableJSON

Details

    • Important

    Description

      The attached schema has top-level AVRO Union type. Whenever the client tries to deserialize the message it fails at parsing field - opt_amount, with stack trace - 

      Caused by: java.lang.ClassCastException: class java.nio.HeapByteBuffer cannot be cast to class java.math.BigDecimal (java.nio.HeapByteBuffer and java.math.BigDecimal are in module java.base of loader 'bootstrap')
      at io.confluent.base.model.Test1.put(Test1.java:115)
      at org.apache.avro.generic.GenericData.setField(GenericData.java:837)
      at org.apache.avro.specific.SpecificDatumReader.readField(SpecificDatumReader.java:139)
      at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:248)
      at org.apache.avro.specific.SpecificDatumReader.readRecord(SpecificDatumReader.java:123)
      at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:180)
      at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:161)
      at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:188)
      at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:161)
      at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:154)
      at io.confluent.kafka.serializers.AbstractKafkaAvroDeserializer$DeserializationContext.read(AbstractKafkaAvroDeserializer.java:400) 

      The sample message you can try is -

      { "io.confluent.base.model.Test1": { "opt_amount": { "bytes": "10.2" } } } 

      Attachments

        1. Test1.avsc
          0.4 kB
          Prathamesh
        2. avro-union-issue.zip
          129 kB
          Prathamesh

        Issue Links

          Activity

            People

              im-pratham Prathamesh
              im-pratham Prathamesh
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3h 40m
                  3h 40m