Uploaded image for project: 'Pentaho Data Integration - Kettle'
  1. Pentaho Data Integration - Kettle
  2. PDI-19263

JSON Input: java.lang.Double cannot be cast to java.math.BigDecimal

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Severity: High
    • Resolution: Unresolved
    • Affects Version/s: 8.3.0 GA, 9.0.0 GA, 9.1.0 GA, 9.2.0 GA
    • Fix Version/s: Backlog
    • Component/s: Step
    • Labels:
      None
    • Story Points:
      0
    • PDI Sub-component:
    • Notice:
      When an issue is open, the "Fix Version/s" field conveys a target, not necessarily a commitment. When an issue is closed, the "Fix Version/s" field conveys the version that the issue was fixed in.
    • Steps to Reproduce:
      Hide

      Steps to replicate the error:

      Show
      Steps to replicate the error: Use the attached transformation NotWorking_With_JSON_Input.ktr and the JSON file testBigNum1.json to replicate the issue. Change the paths as per your environment. Set the execution logging level to DEBUG

      Description

      When using the value 1.7978E308 in a JSON file and trying to read the field using the JSON Input step we get the error as below:

      2021/07/13 16:10:55 - C:\Users\gs\Downloads\102041SampleTransformation (2).ktr : 102041SampleTransformation - Dispatching started for transformation [C:\Users\gs\Downloads\102041SampleTransformation (2).ktr : 102041SampleTransformation]
      2021/07/13 16:10:55 - JSON input.0 - java.lang.Double cannot be cast to java.math.BigDecimal
      2021/07/13 16:10:55 - JSON input.0 - ERROR (version 8.3.0.0-371, build 8.3.0.0-371 from 2019-06-11 11.09.08 by buildguy) : Error running step! 
      2021/07/13 16:10:55 - JSON input.0 - Unexpected conversion error while converting value [BigNum1 String(10)] to a BigNumber
      2021/07/13 16:10:55 - JSON input.0 - 
      2021/07/13 16:10:55 - JSON input.0 - BigNum1 String(10) : couldn't convert string value 'Infinity' to a big number.
      2021/07/13 16:10:55 - JSON input.0 -  at java.lang.Thread.run (Thread.java:748)
      

      I am also attaching the sample transformation NotWorking_With_JSON_Input.ktr NotWorking_With_JSON_Input.ktr

      The JSON input step does not pass the expected classes to the JSON parser. This causes the parser to read the number into a java.lang.Double, whereas PDI is expecting a java.math.BigDecimal. Notice the first error: "java.lang.Double cannot be cast to java.math.BigDecimal"

      https://github.com/pentaho/pentaho-kettle/blob/master/plugins/json/core/src/main/java/org/pentaho/di/trans/steps/jsoninput/reader/FastJsonReader.java#L245

      The second error is caused by the fallback to using a String as an intermediate representation. This also fails because a java.lang.Double cannot contain such a big number and comes out as a string containing "Infinity".

        PractiTest Integration




          Attachments

            Issue Links

              Activity

                People

                Assignee:
                Unassigned Unassigned
                Reporter:
                gdev Gurudev
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated: