Paul Rogers created IMPALA-7964:
-----------------------------------

             Summary: Inconsistent typing of pure-constant expressions
                 Key: IMPALA-7964
                 URL: https://issues.apache.org/jira/browse/IMPALA-7964
             Project: IMPALA
          Issue Type: Bug
          Components: Frontend
    Affects Versions: Impala 3.1.0
            Reporter: Paul Rogers
            Assignee: Paul Rogers


Impala implements a very subtle rule for computing the type of constant 
expressions. See IMPALA-4213. The desired rules when performing constant 
folding are:

* Pure-literal numeric expressions take the natural (smallest) type of the 
result.
* All other expressions preserve the type of the expression.

Examples:

{noformat}
 -- simple literal
100 -> 100:TINYINT

 -- explicit cast
CAST(100 AS SMALLINT) --> 100:SMALLINT

 -- pure literal expression
2 + 3 --> 5:TINYINT

  -- addition is done at next wider type up from that of tinyint_col
tinyint_col + 3 --> SMALLINT

 -- explicit type given, math done with that type, mimics above
CAST(2 AS TINYINT) + 3 --> 5:SMALLINT

 -- Impala uses C++ semantics, with overflow
CAST(257 AS TINYINT) --> 2:TINYINT
{noformat}

At present, some parts of the code follow these rules, but the constant folding 
rule does not. As a result, {{PlannerTest}} fails for subtle changes in 
unrelated areas. Some {{PlannerTest}} results, such as the Kudu test mentioned 
in IMPALA-4213 do observe the rules. But, some constant folding test *do not* 
observe the rules.

Expected that the rules would be followed on all code paths to ensure 
consistent results.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to