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

Calculator step produces incorrect result using BigNumber as datatype.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Severity: Urgent
    • Resolution: Fixed
    • Affects Version/s: 8.2.0.3 GA, 8.2.0 GA, 8.3.0 GA
    • Fix Version/s: 9.0.0 GA
    • Component/s: Step
    • Environment:
      # Environment
      V8.2 environment
      Pentaho version : 8.2.0.3
      OS : Windows 10 Pro
    • Story Points:
      20
    • 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.
    • Sprint Team:
      Tatooine (Maint)
    • Steps to Reproduce:
      Hide

      1. Create input data using [Data grid] step and transform it into the following data types using [Select values] step.

      2. Open the Meta-data tab in [Select values] step and change following data types. 
           Name      Type     
           NumberA    Number    
           NumberB    BigNumber 

      3. In the transformation, add [Calculator] step. Extend a hop from [Select values] to [Calculator] step.

      4. In “[Calculation]” shown in [Calculator] step, select a formula, which is (A*B). The next, specify [NumberB] in FieldA and [NumberA] in FieldB.

      5. Execute the transformation (*2) configured in steps “1.” to “4.” above.

      6. Check the results of [Calculator].

      Show
      1. Create input data using [Data grid] step and transform it into the following data types using [Select values] step. 2. Open the Meta-data tab in [Select values] step and change following data types.       Name      Type           NumberA    Number          NumberB    BigNumber  3. In the transformation, add [Calculator] step. Extend a hop from [Select values] to [Calculator] step. 4. In “ [Calculation] ” shown in [Calculator] step, select a formula, which is (A*B). The next, specify [NumberB] in FieldA and [NumberA] in FieldB. 5. Execute the transformation (*2) configured in steps “1.” to “4.” above. 6. Check the results of [Calculator] .

      Description

      Use Case 1 : Multiplication

      Using a calculator step for multiplying 2 values of datatype *BigNumber* will result in an incorrect result. 

       e.g.) 
      3 * 44 = 130 (Precision definition is 2 because 44 is 2 digits. The first 2 digits of 132 is rounded , then last 1 digit is rounded down. The result is 130.) 
      3 * 444 = 1330 (Precision definition is 3 because 444 is 3 digits. The first 3 digits of 1332 is rounded , then last 1 digit is rounded down. The result is 1330.) 
      99* 5 = 500 (Precision definition is 2 because 99 is 2 digits. The first 2 digits of 495 is rounded , then last 1 digit is rounded up. The result is 500.)

      Result of calculation using BigNumber type is incorrect because of above reason.

       

      Use Case 2 : Division

      If Dividing 2 values of datatype "BigNumber", the calculated value is getting rounded off which would loose precision value. The other thing that I noticed was that the conversion Mask does not have any effect when datatype is BigNumber. 

      For Ex: Suppose Dividing 4389/1291, the output of Calculator Step is showing as 3.4. But the actual result that should be shown is 3.39969016(depending on the conversion mask). I am attaching the sample transformation(Calculator_Dividing_Numbers_BigNumber_datatype.ktr). I have attached a screencast for reference.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              lcarvalho Laura Carvalho
              Reporter:
              jagdeeshss Jagdeeshss
              Votes:
              1 Vote for this issue
              Watchers:
              15 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: