Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-7255

Incorrect result rounding midpoint negative numbers to negative precision

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None
    • None
    • ghx-label-2

    Description

      Based on the Impala docs and on the behavior of other SQL engines, it's evident that:

      round(-15, -1) should return -20
      round(-150, -2) should return -200

      and so on, because negative values at the midpoint between the upper and lower rounded values are supposed to round to the value farther from zero. However, in Impala:

      round(-15, -1) returns -10
      round(-150, -2) returns -100

      and so on. This issue affects cases where both arguments are negative and the number being rounded is at the midpoint. I believe this issue affects cases where the first argument has any of the integer data types or the FLOAT or DOUBLE type, but not when it has a DECIMAL type. This issue seems to occur regardless of whether the numbers being rounded are specified as literals, column references, or expressions.

      To reproduce this, execute queries like:

      SELECT round(-15, -1);
      SELECT round(-150, -2);
      SELECT round(cast(-150 AS BIGINT), -2);
      SELECT round(cast(-150 AS DOUBLE), -2);

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              icook Ian Cook
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: