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

Vladimir Sitnikov commented on CALCITE-2438:
--------------------------------------------

{quote}And I also think we can add some more operator case to the 
RexCall#isAlwaysNull,just like this:
{quote}
As you might see, I had [similar approach a couple of days 
ago|https://github.com/apache/calcite/compare/master...980f491323fcf61f5c966120870b3442cae41c23#diff-66bc135d44f8eb4d99a8882cd740c654R158],
 however I think placing more logic into {{RexCall.isAlways*}} does not really 
help, so I removed extra bits for now.

The case you show would be handled by {{is not null}} simplifications in 
{{RexSimplify}}, and it makes no reason to duplicate that efforts (neither 
makes sense to introduce new bugs!).

Consider the following expression:
{noformat}
$0: nullable int;
($0 is null) AND ($0=42)
{noformat}
None of the implementations in {{RexCall.isAlwaysNull}} would deduce that the 
expression is always null yet RexSimplify would fold that.

 

For instance, current implementation of RexSimplify folds {{$0 is null AND 
$0=42}} expression into {{IS TRUE(false)}}

Note: current implementation is able to fold {{IS TRUE(false)}} into {{false}} 
yet it somehow fails to make both optimizations in one simplify call (it is 
related to my #1 above)

> RexCall#isAlwaysTrue  return incorrect result
> ---------------------------------------------
>
>                 Key: CALCITE-2438
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2438
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: pengzhiwei
>            Assignee: Julian Hyde
>            Priority: Critical
>         Attachments: 屏幕快照 2018-08-02 下午7.26.20.png, 屏幕快照 2018-08-02 
> 下午7.34.26.png
>
>
> In the expression as followed:
> {code:java}
> ((sal IS NULL) IS NOT NULL) IS FALSE
> {code}
> The RexCall#isAlwaysTrue return true,however the correct answer is false.
> I find the reason is that there is a wrong logic in the  isAlwaysTrue,when 
> getKind() is IS_NOT_FALSE、IS_FALSE and IS_NOT_FALSE :
> !屏幕快照 2018-08-02 下午7.34.26.png!
> Can you have a check for me,thanks!



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to