Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.41.0
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
- is a child of
-
CALCITE-7430 3 queries in RelOptRulesTest fail due to TopDownGeneralDecorrelator bugs
-
- Open
-
- links to