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

Julian Hyde commented on CALCITE-5336:
--------------------------------------

"Infer constants from predicates with IS NOT DISTINCT FROM operator" would be 
better

{quote}
I had to use RexBuilder as RelBuilder was not letting me create a RexNode with 
IS_NOT_DISTINCT_FROM (It was simplifying it into a combination of "EQUALS or 
NULL").
{quote}

Makes sense.  Still, use RelBuilder wherever possible, so that your code looks 
similar to code building similar expressions in this test.

{quote}
As I was already having a RexBuilder inside relFn, I created the date literal 
using that only. I am not entirely sure how to implement extending literal to 
accept DateString for testing purpose.
{quote}

I think it's a straightforward change to the RelBuilder.literal() method. Add 
an "else if (value instanceof DateString)" branch.

{quote}
I do need executor, as the rule was not applying the logic without it. (Please 
see  ReduceExpressionsRule.reduceExpressionsInternal).
{quote}

There are other tests that reduce expressions. Why do these not need to create 
an executor?

> Support inferring constants from predicates with IS NOT DISTINCT FROM operator
> ------------------------------------------------------------------------------
>
>                 Key: CALCITE-5336
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5336
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Jasmin Trada
>            Assignee: Jasmin Trada
>            Priority: Trivial
>              Labels: pull-request-available
>             Fix For: 1.33.0
>
>   Original Estimate: 168h
>          Time Spent: 10m
>  Remaining Estimate: 167h 50m
>
> Whenever we have {{IS NOT DISTINCT FROM}} operator in a predicate, the 
> {{predicateConstants}} method in {{RexUtil}} is not able to identify the 
> constants.
> E.g., If we make a predicate as given below,
> {code}
> //dec20 = IS_NOT_DISTINCT_FROM($0, CAST(2020-12-11):DATE)
> RexNode dec20 = rexB.makeCall(IS_NOT_DISTINCT_FROM,
>             rexB.makeInputRef(dateColumnType, 0),
>             rexB.makeLiteral(new DateString(2020, 12, 11), dateColumnType, 
> false));
> {code}
> and if we call {{RexUtil.predicateConstants(RexNode.class, rexB, 
> Arrays.asList(dec20))}},
> it will return an empty map, but it should have returned something like this:
> {code}
> { "$0" -> "CAST(2020-12-11):DATE"}
> {code}



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

Reply via email to