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

Haisheng Yuan commented on CALCITE-3132:
----------------------------------------

Indeed complex. Should {{>($0, $9)}} be enough for this case?

> Simply expressions in LogicalFilter generated for subqueries with quantified 
> predicate
> --------------------------------------------------------------------------------------
>
>                 Key: CALCITE-3132
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3132
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Vineet Garg
>            Assignee: Vineet Garg
>            Priority: Major
>              Labels: sub-query
>
> Following test in RelOptRulesTest generate plan with LogicalFilter
> {code}
> @Test public void testSome() {
>     final String sql = "select * from emp e1\n"
>         + "  where e1.empno > SOME (select deptno from dept)";
>     checkSubQuery(sql).withLateDecorrelation(true).check();
>   }
> {code}
> {code}
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
> SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
>   LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
> SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
>     LogicalFilter(condition=[OR(AND(IS TRUE(>($0, $9)), <>($10, 0)), 
> AND(>($10, $11), null, <>($10, 0), IS NOT TRUE(>($0, $9))), AND(>($0, $9), 
> <>($10, 0), IS NOT TRUE(>($0, $9)), <=($10, $11)))])
>       LogicalJoin(condition=[true], joinType=[inner])
>         LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>         LogicalAggregate(group=[{}], m=[MIN($0)], c=[COUNT()], d=[COUNT($0)])
>           LogicalProject(DEPTNO=[$0])
>             LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
> {code}
> Note that LogicalFilter has condition which should be further simplified
> {code} 
> (condition=[OR(AND(IS TRUE(>($0, $9)), <>($10, 0)), AND(>($10, $11), null, 
> <>($10, 0), IS NOT TRUE(>($0, $9))), AND(>($0, $9), <>($10, 0), IS NOT 
> TRUE(>($0, $9)), <=($10, $11)))])
> {code}
> If {{AND(IS TRUE(>($0, $9)), <>($10, 0))}} is true so will be {{AND(IS 
> TRUE(>($0, $9)), <>($10, 0))}}



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

Reply via email to