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

Subquery in FILTER is left untransformed

    XMLWordPrintableJSON

Details

    Description

      Reproducer

      Query:

      select * from emp 
        where empno IN (select (select max(sal) from emp) from dept)
      

      Plan after SubqueryRemoveRule

      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])
          LogicalJoin(condition=[=($0, $9)], joinType=[inner])
            LogicalTableScan(table=[[CATALOG, SALES, EMP]])
            LogicalAggregate(group=[{0}])
              LogicalProject(EXPR$0=[$SCALAR_QUERY({
      LogicalAggregate(group=[{}], EXPR$0=[MAX($0)])
        LogicalProject(SAL=[$5])
          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      })])
                LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
      

      As you can notice scalar query in LogicalProject is left as it is

      Attachments

        Issue Links

          Activity

            People

              vgarg Vineet Garg
              vgarg Vineet Garg
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m