You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Vineet Garg (JIRA)" <ji...@apache.org> on 2019/06/17 22:25:00 UTC

[jira] [Created] (CALCITE-3132) Simply expressions in LogicalFilter generated for subqueries with quantified predicate

Vineet Garg created CALCITE-3132:
------------------------------------

             Summary: 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


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)