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

AssertionError in new decorrelation algorithm caused by FilterJoinRule omitting variablesSet

    XMLWordPrintableJSON

Details

    Description

      The following SQL will throw an error when run in CoreQuidemTest2:

      SELECT E.EMPNO
      FROM EMP E
      JOIN DEPT D ON E.DEPTNO = D.DEPTNO
      WHERE E.EMPNO > 10 AND D.DEPTNO = (
          SELECT MIN(D_INNER.DEPTNO)
          FROM DEPT D_INNER
          WHERE D_INNER.DEPTNO = E.DEPTNO);
      
      
      java.lang.AssertionError: Correlation variable $cor0 should be defined at org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.getCorrelVariableGetter(EnumerableRelImplementor.java:476)

      The root cause is that FilterJoinRule was applied before the subquery was removed, and when building the top Filter, the variablesSet was omitted. SubQueryRemoveRule.FILTER_SUB_QUERY_TO_MARK_CORRELATE performs a strict check on variablesSet when removing a subquery: if it is empty, a Join will be generated instead of a Correlate. As a result, the plan does not contain a Correlate, but correlated variables remain.

      Attachments

        Issue Links

          Activity

            People

              dongsl Silun Dong
              dongsl Silun Dong
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: