Uploaded image for project: 'CDAP'
  1. CDAP
  2. CDAP-15570

Can not get the decimal logical type field of StructuredRecord from MockSource

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 6.1.0
    • Fix Version/s: None
    • Component/s: Test
    • Labels:
      None
    • Rank:
      1|i00p73:

      Description

      Can not use getDecimal method of the StructuredRecord instance obtained using MockSource.

      Implementation of the StructuredRecord#getDecimal method assumes field value to be raw bytes array but this field got wrapped into ByteBuffer by JsonDecoder#readBytes during StructuredRecord deserialization from JSON string.
      Thus, calling StructuredRecord#getDecimal method leads to the following exception:

      java.lang.ClassCastException: java.nio.HeapByteBuffer cannot be cast to [B
      	at io.cdap.cdap.api.data.format.StructuredRecord.getDecimal(StructuredRecord.java:188)
      	at io.cdap.test.DecimalTest.testWithMock(DecimalTest.java:87)
      

      Test to reproduce the issue can be found in the attachments:

      $ tar -xzvf decimal-logical-test.tar.gz
      $ cd decimal-logical-test/
      $ mvn test
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vladhlinskiy Vlad Hlinskiy
                Reporter:
                vladhlinskiy Vlad Hlinskiy
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: