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

Calculator ROUND (A) function uses a different rounding method than ROUND (A, B)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Severity: Urgent
    • Resolution: Fixed
    • Affects Version/s: 4.1.0 GA (Platform Release 3.7.0), 4.2.0 GA (4.0.0 GA Suite Release), 4.3.0 GA (4.5.0 GA Suite Release), 4.4.0 GA (4.8.0 GA Suite Release) , 5.0.0 GA (5.0.0 GA Suite Release)
    • Fix Version/s: 6.0.0 GA
    • Component/s: Step
    • 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:
      Maintenance

      Description

      This has not been reported yet, but was found by implementing the Calculator function STDROUND by PDI-1311 (New Calculator Calculation Type to support standard rounding) and creating validation samples:

      ROUND (A)

      • it uses round(ValueMetaInterface metaA, Object dataA) that performs a Math.round(): Returns the closest Integer to the argument

      ROUND (A,B)

      • uses not the Math.round but methods with the rounding method ROUND_HALF_EVEN

      This leads to different rounding methods with or without precision, please see the attached example.
      The newly implemented STDROUND (A) or STRDOUND (A,B) uses consistent ROUND_HALF_UP

      Notes:
      a) Since the implementation of PDI-1311, the different behavior is documented over here: http://wiki.pentaho.com/display/EAI/Calculator
      b) By fixing the existing code, this would have backward compatibility impact
      c) New rounding functions should be used when implementing a consistent rounding for:
      1) Returns the closest Integer to the argument
      2) Method "Round half to even"

        Attachments

        1. PDI-9920_rounding.ktr
          15 kB
        2. PDI-9920_roundingInt.ktr
          18 kB
        3. ROUND_CUSTOM-bottom.png
          ROUND_CUSTOM-bottom.png
          7 kB
        4. ROUND-middle.png
          ROUND-middle.png
          3 kB

          Issue Links

            Activity

              People

              Assignee:
              aliaksandr Aliaksandr Bialkevich (Inactive)
              Reporter:
              jbleuel Jens Bleuel
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: