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
CREATETABLEt0 (g INT);
CREATETABLEt1 (a INT);
CREATETABLEt2 (c INT);
INSERT INTO t0 VALUES (1), (2);
INSERT INTO t1 VALUES (10);
INSERT INTO t2 VALUES (1);
-- Outer-outer column `t0.g` is referenced only at the deepest level-- (t2.c = t0.g). The middle EXISTS (over t1) has no direct reference-- to t0, so its Subquery.outer_ref_columns gets populated as empty.SELECT g FROM t0 WHERE EXISTS (
SELECT1FROM t1 WHERE EXISTS (
SELECT1FROM t2 WHEREt2.c=t0.g
)
);
-->
Schema error: No field named t0.g. Valid fields are __correlated_sq_1.c.
changed the title [-]Grandparent column reference in nested subquery causes planner error[/-][+][dbolympics] Grandparent column reference in nested subquery causes planner error[/+]on Oct 24, 2026
in my opinion WE SHOULD NOT try and extend the existing subquery rewrites to support this type of query as that risks introducing many more wrong results, see #5492 (comment)
Activity
neilconway commentedon Apr 18, 2026
take
neilconway commentedon Apr 22, 2026
Probably a dup of #15558
[-]Grandparent column reference in nested subquery causes planner error[/-][+][dbolympics] Grandparent column reference in nested subquery causes planner error[/+]alamb commentedon Oct 24, 2026
Affects DB Olympics, see: #26661
alamb commentedon Oct 28, 2026
I think we should implement support support for this feature as part of the more general subquery decorrelation project described here
in my opinion WE SHOULD NOT try and extend the existing subquery rewrites to support this type of query as that risks introducing many more wrong results, see #5492 (comment)
fix: column ids, stage 9: outer references two levels up, no allowlist