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

Yu Xu commented on CALCITE-7122:
--------------------------------

OK, according to the discussion plan, the first step is to solve the 
idempotency elimination of unary functions. As shown in the 
PR(https://github.com/apache/calcite/pull/4488), the currently known unary 
idempotent functions have been added to IDEMOTENT_UNARY_FUNCTIONS 
(UPPER/LOWER/INITCAP/ABS).


If there is a need to add unary idempotent functions in the future, developers 
can simply add them to this list IDEMOTENT_UNARY_FUNCTIONS to quickly eliminate 
idempotency. I think this PR is ready for review. 


In addition, the idempotency elimination of CAST has been implemented before. 
For details, please refer to the judgment in RexSimplify.simplifyCast. eg:
{code:java}
select CAST(CAST(\"salary\" AS DOUBLE) AS DOUBLE) from \"employee\" {code}
would simplify to
{code:java}
select CAST(\"salary\" AS DOUBLE) from \"employee\" {code}

> Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP 
> ------------------------------------------------------------------------------
>
>                 Key: CALCITE-7122
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7122
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.40.0
>            Reporter: Yu Xu
>            Assignee: Yu Xu
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.41.0
>
>
> Unary functions like upper/lower/abs are idempotent( f(f(...fx))—> fx, but 
> currently had not eliminate idempotency for them.
> eg:
>  
> {code:java}
> SELECT LOWER(LOWER('AAA')) {code}
> would convert to:
>  
> {code:java}
> SELECT LOWER(LOWER('AAA')){code}
> should would better simplify to
>  
> {code:java}
> SELECT LOWER('AAA') {code}
>  
>  
> Because the idempotency elimination of unary functions is relatively simple, 
> we can design a mechanism to simplify.



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

Reply via email to