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

pengzhiwei edited comment on CALCITE-2555 at 9/19/18 4:45 AM:
--------------------------------------------------------------

[~vladimirsitnikov] There is a problem when using Strong.isNull for 
RexSimplify.The case "null not in null non-correlated" generated a wrong result.
{code:java}
# Test project null NOT IN null non-correlated
select sal,
  cast(null as int) NOT IN (
    select cast(null as int)
    from "scott".dept)
from "scott".emp;
 SAL     | EXPR$1
---------+--------
 1100.00 | true
 1250.00 | true
 1250.00 | true
 1300.00 | true
 1500.00 | true
 1600.00 | true
 2450.00 | true
 2850.00 | true
 2975.00 | true
 3000.00 | true
 3000.00 | true
 5000.00 | true
  800.00 | true
  950.00 | true
(14 rows)
{code}
The correct result should be "null" but not "true".

So I think there is a risk to do this.


was (Author: pzw2018):
[~vladimirsitnikov] There is a problem when using Strong.isNull for 
RexSimplify.The case "null not in null non-correlated" generated wrong result.
{code:java}
# Test project null NOT IN null non-correlated
select sal,
  cast(null as int) NOT IN (
    select cast(null as int)
    from "scott".dept)
from "scott".emp;
 SAL     | EXPR$1
---------+--------
 1100.00 | true
 1250.00 | true
 1250.00 | true
 1300.00 | true
 1500.00 | true
 1600.00 | true
 2450.00 | true
 2850.00 | true
 2975.00 | true
 3000.00 | true
 3000.00 | true
 5000.00 | true
  800.00 | true
  950.00 | true
(14 rows)
{code}
The correct result should be "null" but not "true".

So I think there is a risk to do this.

> RexSimplify: >=(true, null) could be simplified to null
> -------------------------------------------------------
>
>                 Key: CALCITE-2555
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2555
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: Vladimir Sitnikov
>            Assignee: Julian Hyde
>            Priority: Major
>              Labels: newbie
>
> {code:java}
> @Test public void simplifyComparisonWithNull() {
>   checkSimplify2(ge(trueLiteral, falseLiteral), "true", "true");
>   checkSimplify2(ge(trueLiteral, nullBool), "null", "false");
>   checkSimplify2(ge(nullBool, nullBool), "null", "false");
> }
> {code}



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

Reply via email to