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

xiong duan commented on CALCITE-5036:
-------------------------------------

Sorry for causing this inconvenience. Next time, I will create a new ISSUE 
record to document such problems.

In the previous PR 
[a81cfb2|https://github.com/apache/calcite/commit/a81cfb2ad001589929e190939cf4db928ebac386],
 performance issues might arise by executing RexSimplify in 
RelMdPredicates#getPredicates to transform a IS NOT DISTINCT FROM b.

Therefore, in the subsequent PR submitted later 
[d9363a9|https://github.com/apache/calcite/commit/d9363a952ce2e1905cca62cdee66076424267503],
 I removed the RexSimplify method in RelMdPredicates#getPredicates and instead 
transformed a IS NOT DISTINCT FROM b in advance by adding 
`CoreRules.FILTER_REDUCE_EXPRESSIONS`.

Since `CoreRules.FILTER_REDUCE_EXPRESSIONS` is an existing optimization, no new 
optimization was introduced here. It changed the implementation.

> `RelMetadataQuery#getPulledUpPredicates` support to analyze constant key for 
> the operator of IS_NOT_DISTINCT_FROM
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-5036
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5036
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Xurenhe
>            Assignee: Xurenhe
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.31.0
>
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> As we know, `IS NOT DISTINCT FROM` is NULL-Safe equal operator.
> The expression of "{*}`a` IS NOT DISTINCT FROM 10{*}" is equal to "{*}(`a` = 
> 10) IS TRUE{*}".
> Currently, `RelMetadataQuery#getPulledUpPredicates` could analyze the 
> constant from the constant's equal condition in the filter, not support `IS 
> NOT DISTINCT FROM`
> {code:java}
> -- sql
> SELECT deptno,
>        mgr,
>        ename
> FROM emp
> WHERE deptno IS NOT DISTINCT FROM 10{code}
> By the way, `deptno` need be rewritten to the constant project with number of 
> 10, when applying the rule of {*}CoreRules#PROJECT_REDUCE_EXPRESSION{*}S



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

Reply via email to