[ https://issues.apache.org/jira/browse/IMPALA-7967?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul Rogers reassigned IMPALA-7967: ----------------------------------- Assignee: (was: Paul Rogers) > Incorrect decimal size in V2 for a numeric const cast to BIGINT > --------------------------------------------------------------- > > Key: IMPALA-7967 > URL: https://issues.apache.org/jira/browse/IMPALA-7967 > Project: IMPALA > Issue Type: Bug > Components: Frontend > Affects Versions: Impala 3.1.0 > Reporter: Paul Rogers > Priority: Major > > Decimal version 2 introduces revised rules for computing decimal width. For > example: > {noformat} > CAST(1 AS DECIMAL(10, 0)) + CAST(2 AS DECIMAL(19,0)) --> DECIMAL(20,0) > {noformat} > The FE uses rules to convert from one type to another. The rule to convert > from {{BIGINT}} to {{DECIMAL}} is: > {noformat} > BIGINT --> DECIMAL(19,0) > {noformat} > Put these two together: > {noformat} > CAST(1 AS DECIMAL(10, 0)) + CAST(2 AS BIGINT) > {noformat} > The result should be {{DECIMAL(20,0)}}. But, because of a bug in the way > constant folding works, the result is actually {{DECIMAL(11,0)}} as seen in > {{AnalyzeExprsTest.TestDecimalArithmetic()}}: > {code:java} > testDecimalExpr(decimal_10_0 + " + cast(1 as bigint)", > ScalarType.createDecimalType(11, 0)); > {code} > It seems one reason the bug was not caught is that the unit tests only check > for constants, not for columns. Modify the tests to work against > {{functional.alltypes}} (they currently work without a table), and substitute > {{bigint_col}} for {{CAST(2 AS BIGINT)}}. > Expected that the code should have followed the rules described above whether > the values are a column, or a constant explicitly cast to the same type as > the column. (Constants without out a cast should follow rules for their > "natural type" which is what appears to be incorrectly happening in the test > case above.) -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-all-unsubscr...@impala.apache.org For additional commands, e-mail: issues-all-h...@impala.apache.org