[ 
https://issues.apache.org/jira/browse/CALCITE-6453?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

xiong duan resolved CALCITE-6453.
---------------------------------
    Fix Version/s: 1.38.0
       Resolution: Fixed

> Simplify casts which are result of constant reduction
> -----------------------------------------------------
>
>                 Key: CALCITE-6453
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6453
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Krisztian Kasa
>            Assignee: Krisztian Kasa
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.38.0
>
>
> RexSimplify transforms nullable cast expressions with a non-nullable literal 
> operand which type is different from the cast type to another cast expression 
> with a literal operand with the same type as the cast.
> If simplify is called again using the result cast expression of the first 
> simplification we get a literal only as a result.
> Example:
> Initial expression
> {code:java}
> CAST(_UTF-16LE'2020-10-30':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"):DATE
> {code}
> where the operand is non-nullable varchar and the result of the cast is 
> nullable date.
> After the first simplify call we get
> {code:java}
> CAST(2020-10-30:DATE):DATE
> {code}
> where the operand type is non-nullable date and the cast type is nullable 
> date.
> https://github.com/apache/calcite/blob/8ab0b03326730aa2cc6b476b2cbd8f99799bdacb/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L2269-L2276
> After the second simplify call we get
> {code:java}
> 2020-10-30:DATE
> {code}
> where the literal type is non-nullable date
> https://github.com/apache/calcite/blob/8ab0b03326730aa2cc6b476b2cbd8f99799bdacb/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L2195-L2196



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

Reply via email to