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

Zhen Chen resolved CALCITE-7042.
--------------------------------
    Resolution: Fixed

> Eliminate nested TRIM calls, exploiting the fact that TRIM is idempotent
> ------------------------------------------------------------------------
>
>                 Key: CALCITE-7042
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7042
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.39.0
>            Reporter: Yu Xu
>            Assignee: Yu Xu
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.41.0
>
>
> Trim function does not have idempotency simplification currently, 
> trim(...trim(' aa ')) should be convert to trim(' aa ').
> sql:
> {code:java}
> select trim(trim(' aa ')); {code}
> plan:
> {code:java}
> EnumerableCalc(expr#0=[{inputs}], expr#1=[FLAG(BOTH)], expr#2=[' '], 
> expr#3=[' aa '], expr#4=[TRIM($t1, $t2, $t3)], expr#5=[TRIM($t1, $t2, $t4)], 
> EXPR$0=[$t5]) 
>    EnumerableValues(tuples=[[{ 0 }]]){code}
> should convert to plan would be better:
> {code:java}
> EnumerableCalc(expr#0=[{inputs}], expr#1=[FLAG(BOTH)], expr#2=[' '], 
> expr#3=[' aa '], expr#4=[TRIM($t1, $t2, $t3)], EXPR$0=[$t4])
>   EnumerableValues(tuples=[[{ 0 }]]) {code}
>  
> sql:
> {code:java}
> select trim(both 'c' from trim(both 'c' from ' aa ')); {code}
> should be:
> {code:java}
> select trim(both 'c' from ' aa '); {code}
> plan:
> {code:java}
> EnumerableCalc(expr#0=[{inputs}], expr#1=[FLAG(BOTH)], expr#2=[' '], 
> expr#3=[' aa '], expr#4=[TRIM($t1, $t2, $t3)], expr#5=[TRIM($t1, $t2, $t4)], 
> EXPR$0=[$t5]) 
>    EnumerableValues(tuples=[[{ 0 }]]){code}
> should convert to plan would be better:
> {code:java}
> EnumerableCalc(expr#0=[{inputs}], expr#1=[FLAG(BOTH)], expr#2=['c'], 
> expr#3=[' aa '], expr#4=[TRIM($t1, $t2, $t3)], EXPR$0=[$t4])
>     EnumerableValues(tuples=[[{ 0 }]]) {code}
>  
> Maybe we can just optimize it.



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

Reply via email to