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

Different results from power() with cast decimal expression vs. the equivalent literal value as base parameter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • Impala 2.3.0
    • None
    • Backend
    • None
    • CDH 5.5.2 (Isilon)

    Description

      The script below highlights the issue we are seeing. If the result of CAST(base as DECIMAL) is provided to power() as a literal the result is ~0.0001% different as compared to when substituting the CAST expression as the base parameter.

      Running the same test in Hive 1.1.0 the two alternatives produce the same result (to the 16th decimal place).

      Is this expected behavior in Impala?

      {{
      CREATE TABLE test_power (base DECIMAL(29,5), exponent DECIMAL(11,0));
      INSERT INTO test_power VALUES(0.03740,43);

      SELECT
      CAST(base as DECIMAL(38,16)) AS cast_base_result,
      POWER(0.0374000000000000, -1 * exponent) AS power_result_using_literal_base,
      POWER(CAST(base as DECIMAL(38,16)), -1 * exponent) AS power_result_using_decimal_expr_base
      FROM test_power
      }}

      ------------------------------------------- output ---------------------------------------
      cast_base_result=0.0374000000000000
      power_result_using_literal_base=2.3255254965315044e+61
      power_result_using_decimal_expr_base=2.3255282221097883e+61

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              curtis_impala_c85a Curtis Howard
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: