Grandparent column reference in nested subquery causes planner error
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Describe the bug
```sql
CREATE TABLE t0 (g INT);
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (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 (
SELECT 1 FROM t1 WHERE EXISTS (
SELECT 1 FROM t2 WHERE t2.c = t0.g
)
);
```
-->
```
Schema error: No field named t0.g. Valid fields are __correlated_sq_1.c.
```
### To Reproduce
_No response_
### Expected behavior
_No response_
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.