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

Julian Hyde commented on CALCITE-4507:
--------------------------------------

I agree, {{a = 0 or a is null}} should return UNKNOWN when a is null.

There is already a test in {{RexProgramTest}} called {{testSimplifyInOr}}, and 
it is not the same as the code you have written above. In my branch fixing 
CALCITE-4446 I have already written tests such as 
{{testSimplifyEqOrIsNullAndEq}}. I think you will agree that this is a 
duplicate of CALCITE-4446.


> 'a = 0 or a is null' should not be rewrite to a sarg 'a in (0, null)'
> ---------------------------------------------------------------------
>
>                 Key: CALCITE-4507
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4507
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.26.0
>            Reporter: Danny Chen
>            Priority: Major
>
> SQL statements:
> {code:sql}
> a = 0 or a is null -- returns true when a is null
> a in (0, null) -- returns null when a is null
> {code}
> have different semantics when {{a}} is null, we should not represent it as a 
> sarg after {{RexSimplify}},
> check this test in {{RexProgramTest}}:
> {code:java}
> @Test void testSimplifyInOr() {
>         or(
>             gt(vInt(), literal(0)),
>             isNull(vInt())),
>         ">(?0.int0, 0)");
>   }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to