You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Paul Rogers (JIRA)" <ji...@apache.org> on 2018/11/26 16:52:00 UTC

[jira] [Created] (IMPALA-7886) NumericLiteral constructor fails to round values to Decimal type

Paul Rogers created IMPALA-7886:
-----------------------------------

             Summary: NumericLiteral constructor fails to round values to Decimal type
                 Key: IMPALA-7886
                 URL: https://issues.apache.org/jira/browse/IMPALA-7886
             Project: IMPALA
          Issue Type: Bug
          Components: Frontend
    Affects Versions: Impala 3.0
            Reporter: Paul Rogers
            Assignee: Paul Rogers


According to the SQL spec, section 4.4, regarding numeric assignment:

bq. If least significant digits are lost, implementation defined rounding or truncating occurs, with no exception condition being raised

When creating a {{NumericLiteral}} via the constructor, no rounding occurs. The value has more precision than specified by the type.

Create a NumericLiteral and test it as follows:

{code:java}
    NumericLiteral n = new NumericLiteral(new BigDecimal("1.567"),
        ScalarType.createDecimalType(2, 1));
    assertEquals(ScalarType.createDecimalType(2, 1), n.getType());
    assertEquals("1.6", n.getValue().toString());
{code}

The above test fails because the value in the literal is “1.567”, it has not been rounded to fit the type of the literal as required by the SQL standard.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org