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

duan xiong edited comment on CALCITE-4805 at 9/26/21, 9:26 PM:
---------------------------------------------------------------

[~julianhyde] HI. Sorry, I don't describe it clearly. When I find when The IN 
sub-query can't be converted to OR when the value list contains Null. And 
According to understanding, The OR condition can handle 3-Valued Logic very 
well. I don't find any other reasons don't convert It.

If as you mentioned above, this line was added to fix a bug, Then we need a 
unit test to protect it. (Before the PR, I have searched the related ISSUE, And 
I don't find the reason). So I think this is an improvement.   


was (Author: nobigo):
[~julianhyde] HI. Sorry, I don't describe it clearly. When I find when The IN 
sub-query can't be converted to OR when the value list contains Null. And 
According to understanding, The condition can handle 3-Valued Logic very well. 
I don't find any other reasons don't convert It.

If as you mentioned above, this line was added to fix a bug, Then we need a 
unit test to protect it. (Before the PR, I have searched the related ISSUE, And 
I don't find the reason). So I think this is an improvement.   

> The IN sub-query can't be converted to OR when value list contains Null.
> ------------------------------------------------------------------------
>
>                 Key: CALCITE-4805
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4805
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: duan xiong
>            Assignee: duan xiong
>            Priority: Major
>
> for example:
> {code:java}
> select * from emp where deptno in (null,2){code}
> Now the RelNode is:
> {code:java}
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
> SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
>  LogicalJoin(condition=[=($7, $9)], joinType=[inner])
>  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>  LogicalAggregate(group=[{0}])
>  LogicalValues(tuples=[[{ null }, { 2 }]]){code}
> The RelNode should be:
> {code:java}
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
> SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
>  LogicalFilter(condition=[OR(=($7, null), =($7, 2))])
>  LogicalTableScan(table=[[CATALOG, SALES, EMP]]){code}
> So I think when the sub-query value list size is under the 
> threshold(IN_SUB_QUERY_THRESHOLD), they can be converted to OR(no matter have 
> the NullLiteral or not). 



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

Reply via email to