[
https://issues.apache.org/jira/browse/CALCITE-7122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18012021#comment-18012021
]
Yu Xu commented on CALCITE-7122:
--------------------------------
[~julianhyde] Thanks for providing so many use cases. Indeed idempotent
functions are numerous, and I believe they can be categorized into two types:
unary functions (upper/lower/abs/initcap) and multi-ary functions (multi-ary
functions).
Unary functions (upper/lower/abs/initcap) can be made idempotent using a simple
mechanism, similar to the method described in the PR, by simply appending them
to the list to be processed.
For multi-ary idempotent functions, similar to CALCITE-7042(note: currently
CALCITE parses LTRIM and RTRIM as TRIM (LEADING/TAILING...), so I understand
that this has eliminated idempotence.), we've found that more diverse decision
logic is required. So, based on the title of this issue, can we focus on unary
functions first, and then open a separate JIRA to address the logic for
multi-ary idempotent functions in the future? WDYT
> Eliminate nested calls for idempotent unary functions upper/lower/abs
> ---------------------------------------------------------------------
>
> 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)