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

Wrong Plan/Result if wrapping a query with SELECT * FROM

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • core
    • None

    Description

      For example, a query such as

      select * from (
          select t1.deptno, t2.deptno
          from emp t1 inner join dept t2
          on t1.empno = t2.deptno
      )
      

      gives a plan:

      LogicalProject(DEPTNO=[$0], DEPTNO0=[$0])
        LogicalProject(DEPTNO=[$7], DEPTNO0=[$9])
          LogicalJoin(condition=[=($0, $9)], joinType=[inner])
            LogicalTableScan(table=[[CATALOG, SALES, EMP]])
            LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
      

      As the top LogicalProject indicates, although DEPTNO and DEPTNO0 coming from different tables, Calcite thinks they are the same so just pick $0.

      Notice if we remove the outermost select * where (), Calcite would not be confused with those two columns.

      Attachments

        Activity

          People

            seanhychu Sean Hsuan-Yi Chu
            seanhychu Sean Hsuan-Yi Chu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: