You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Correlated subquery fails with "No field named" when a JOIN ... ON in the subquery reads an outer column #27801
A correlated subquery fails to plan when the ON clause of a join inside the subquery reads an outer column.
To Reproduce
CREATETABLEt (a INT) ASVALUES (1), (2), (4);
CREATETABLEi (a INT) ASVALUES (1), (2), (2), (3);
CREATETABLEu (b INT) ASVALUES (10), (20);
SELECTo.aFROM t o WHERE EXISTS (
SELECT1FROM i JOIN u ONu.b>o.a*5
) ORDER BYo.a;
DataFusion main:
DataFusion error: Optimizer rule 'simplify_expressions' failed
caused by
Schema error: No field named o.a. Did you mean 't.a'?
Valid fields are t.a, __correlated_sq_2.b.
The same happens with a correlated WHERE as well (... ON u.b > o.a * 5 WHERE i.a = o.a).
Expected behavior
1, 2 (DuckDB 2.0.1), or a "not implemented" error if this shape can't be decorrelated.
Additional context
The outer reference in the join filter seems to survive decorrelation as a plain o.a column. This is different from #27781 , where the subquery itself is in the outer query's JOIN ... ON. Found while testing #27783 .
Willingness to contribute
I cannot contribute a fix for this bug at this time
Activity