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

Erroneous correlate variables in case of using collect sub-queries into ARRAY, MAP and MULTISET.

    XMLWordPrintableJSON

Details

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

    Description

      Query like:

      select name,
          array (select *
              from emp
              where deptno = dept.deptno) as emp_array,
          multiset (select *
              from emp
              where deptno = dept.deptno) as emp_multiset,
          map (select empno, job
              from emp
              where deptno = dept.deptno) as job_map
      from dept
      

      must generate one correlate variable for all nested sub-queries, instead we erroneously obtain 3 different variables ($cor0.DEPTNO, $cor1.DEPTNO, $cor2.DEPTNO):

      LogicalProject(NAME=[$1], EMP_ARRAY=[ARRAY({
      LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
        LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      })], EMP_MULTISET=[MULTISET({
      LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
        LogicalFilter(condition=[=($7, $cor1.DEPTNO)])
          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      })], JOB_MAP=[MAP({
      LogicalProject(EMPNO=[$0], JOB=[$2])
        LogicalFilter(condition=[=($7, $cor2.DEPTNO)])
          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      })])
        LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
      

      This issue is started from CALCITE-4673 (see comment), and also additional tests.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              zstan Evgeny Stanilovsky
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: