[ 
https://issues.apache.org/jira/browse/IMPALA-11462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17615743#comment-17615743
 ] 

Daniel Becker commented on IMPALA-11462:
----------------------------------------

If both operands are literals, expression rewrite will execute the shift 
operation and replace the expression with literal 128.

If the second operand is not a literal, the expression cannot be evaluated by 
the rewriter. On the other hand, the cast to bigint will be folded into the 
literal during expression rewrite. This modifies the expression, so re-analysis 
is needed. Re-analysis resets the literal expression (a NumericLiteral), which 
loses its type and becomes TINYINT again.

The problem is that when FoldConstantsRule folds the cast into the literal, it 
doesn't set its explicit type, and only its implicit type becomes BIGINT (for 
the various types of NumericLiterals, see 
[https://github.com/apache/impala/blob/11157a87016fc2408a5ae649aed7cdfb8a0e5d3b/fe/src/main/java/org/apache/impala/analysis/NumericLiteral.java#L41).]

In the case where expression rewrite is disabled, no re-analysis takes place so 
the literal and its type are not reset.

The solution is to set the explicit type of NumericLiteral when folding the 
cast into it.

> shiftleft problem
> -----------------
>
>                 Key: IMPALA-11462
>                 URL: https://issues.apache.org/jira/browse/IMPALA-11462
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Clients
>    Affects Versions: Impala 3.4.1
>            Reporter: jack sun
>            Assignee: Daniel Becker
>            Priority: Minor
>         Attachments: screenshot-1.png
>
>
> if change the second param of function 'shiftleft' as a dynamic value , it 
> will change the first param as tinnyint
>  !screenshot-1.png! 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to