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

Incorrect NumericLiteral overflow checks for FLOAT, DOUBLE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • Impala 3.0
    • None
    • Frontend
    • None
    • ghx-label-1

    Description

      Consider the following (new) unit test:

          assertFalse(NumericLiteral.isOverflow(BigDecimal.ZERO, Type.FLOAT));
      

      This test fails (that is, the value zero, so the method claims, overflows a FLOAT.)

      The reason is a misunderstanding of the meaning of MIN_VALUE for Float:

            case FLOAT:
              return (value.compareTo(BigDecimal.valueOf(Float.MAX_VALUE)) > 0 ||
                  value.compareTo(BigDecimal.valueOf(Float.MIN_VALUE)) < 0);
      

      For Float, MIN_VALUE is the smallest positive number that Float can represent:

          public static final float MIN_VALUE = 0x0.000002P-126f; // 1.4e-45f
      

      The value that the Impala code wants to check it - Float.MAX_VALUE.

      The only reason that this is not marked as more serious is that the method appears to be used in only one place, and that place does not use FLOAT values.

      Attachments

        Issue Links

          Activity

            People

              Paul.Rogers Paul Rogers
              Paul.Rogers Paul Rogers
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: