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

Complicated logical plan generated for in subquery with non-equi condition

    XMLWordPrintableJSON

Details

    Description

      Repro:
      Add the following test to SqlToRelConverterTest.java.

      @Test public void testSubQueryIN() {
          final String sql = "select deptno\n"
              + "from EMP e\n"
              + "where deptno in (select deptno\n"
              + "from EMP where empno=e.empno+1)";
          sql(sql).ok();
        }
      

      Plan:

      LogicalProject(DEPTNO=[$7])
        LogicalJoin(condition=[AND(=($0, $10), =($7, $9))], joinType=[inner])
          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
          LogicalAggregate(group=[{0, 1}])
            LogicalProject(DEPTNO=[$7], EMPNO0=[$9])
              LogicalJoin(condition=[=($0, +($9, 1))], joinType=[inner])
                LogicalTableScan(table=[[CATALOG, SALES, EMP]])
                LogicalProject(EMPNO=[$0])
                  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      

      One join would suffice.

      Attachments

        Issue Links

          Activity

            People

              danny0405 Danny Chen
              hyuan Haisheng Yuan
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

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