You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Stamatis Zampetakis (Jira)" <ji...@apache.org> on 2026/05/22 08:04:00 UTC
[jira] [Updated] (CALCITE-7434) AssertionError in new decorrelation algorithm caused by FilterJoinRule omitting variablesSet
[ https://issues.apache.org/jira/browse/CALCITE-7434?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stamatis Zampetakis updated CALCITE-7434:
-----------------------------------------
Summary: AssertionError in new decorrelation algorithm caused by FilterJoinRule omitting variablesSet (was: Error in new decorrelation algorithm caused by FilterJoinRule omitting variablesSet)
> AssertionError in new decorrelation algorithm caused by FilterJoinRule omitting variablesSet
> --------------------------------------------------------------------------------------------
>
> Key: CALCITE-7434
> URL: https://issues.apache.org/jira/browse/CALCITE-7434
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.41.0
> Reporter: Silun Dong
> Assignee: Silun Dong
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.42.0
>
>
> The following SQL will throw an error when run in CoreQuidemTest2:
> {code:java}
> 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){code}
> The root cause is that {{FilterJoinRule}} was applied before the subquery was removed, and when [building the top Filter|https://github.com/apache/calcite/blob/7654dd82162508231cb3ed44e60fed356e931403/core/src/main/java/org/apache/calcite/rel/rules/FilterJoinRule.java#L251], 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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)