Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-3132

Simply expressions in LogicalFilter generated for subqueries with quantified predicate

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core
    • Labels:

      Description

      Following test in RelOptRulesTest generate plan with LogicalFilter

      @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();
        }
      
      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]])
      

      Note that LogicalFilter has condition which should be further simplified

       
      (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)))])
      

      If AND(IS TRUE(>($0, $9)), <>($10, 0)) is true so will be AND(IS TRUE(>($0, $9)), <>($10, 0))

        Attachments

          Activity

            People

            • Assignee:
              vgarg Vineet Garg
              Reporter:
              vgarg Vineet Garg
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: