[
https://issues.apache.org/jira/browse/CALCITE-5759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17731144#comment-17731144
]
Runkang He edited comment on CALCITE-5759 at 6/10/23 1:44 AM:
--------------------------------------------------------------
For how to fix it, a reasonable way is to re-simplify the initially simplified
result of special sarg in [1]. And this is the same way used by [2] when
simplify comparaion.
[1][https://github.com/apache/calcite/blob/2e3e4ae220a69a0936792caec1fae23d947e77f3/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L2128]
[2][https://github.com/apache/calcite/blob/2e3e4ae220a69a0936792caec1fae23d947e77f3/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L525]
was (Author: JIRAUSER280488):
For how to fix it, a reasonable way is to re-simplify the initially simplified
result of special sarg in [1]. This is the same way used by [2] when simplify
comparaion.
[1][https://github.com/apache/calcite/blob/2e3e4ae220a69a0936792caec1fae23d947e77f3/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L2128]
[2][https://github.com/apache/calcite/blob/2e3e4ae220a69a0936792caec1fae23d947e77f3/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L525]
> SEARCH operator with special sarg is not fully simplified
> ---------------------------------------------------------
>
> Key: CALCITE-5759
> URL: https://issues.apache.org/jira/browse/CALCITE-5759
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.34.0
> Reporter: Runkang He
> Assignee: Runkang He
> Priority: Major
>
> The minimal reproducer is to construct a RexCall with RexUnknownAs.FALSE as
> below:
> {code:sql}
> SEARCH(1, Sarg[IS NOT NULL])
> {code}
> After RexSimplify#simplifySearch, the final simplified result is IS NOT
> NULL(1), which should be TRUE more thoroughly.
> Also, the following RexCall with RexUnknownAs.TRUE:
> {code:sql}
> SEARCH(1, Sarg[IS NULL])
> {code}
> Is simplified to IS NULL(1), which should be FALSE.
> Another two cases:
> The following RexCall with RexUnknownAs.UNKNOWN:
> {code:sql}
> SEARCH(1, Sarg[=])
> {code}
> Is simplified to 1 IS NOT NULL OR NULL, which should be TRUE.
> The following RexCall with RexUnknownAs.UNKNOWN:
> {code:sql}
> SEARCH(1, Sarg[<>])
> {code}
> Is simplified to 1 <> 1, which should be FALSE.
> Note that current simplified result is inconsistent with
> RexCall.isAlwaysFalse and isAlwaysTrue.
> Therefore, for the above two reasons, I think we need to simplify SEARCH
> operator with special sarg more thoroughly.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)