dolthub / dolthub/dolt

Nested `SubqueryAliases` in `Lateral` Joins

Open
#6,872 0 comments 0 reactions 1 assignee Claimed by @zachmu View on GitHub
analyzer bug sql
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 5h
Merged PRs (30d)
108

Description

This PR: https://github.com/dolthub/go-mysql-server/pull/2095

Fixes some issues regarding nested SubqueryAlias in lateral joins by making these nested subqueries have visibility to the entire left scope. This could potentially cause problems when we only want prepend a subset of the columns from outer scopes.

I believe we aren't close to fixing this the correct way.

Some examples of queries that share this pattern.
```sql
create table t1 (i int primary key);
create table t2 (j int primary key);
create table t3 (k int primary key);
insert into t1 values (1);
insert into t2 values (2);
insert into t3 values (3);
select * from t1, lateral (select * from t2, (select * from t3 where i = 1) sqa1) sqa2; -- works in mysql, fails in dolt
select * from t1, lateral (select * from t2, (select * from t3 where j = 2) sqa1) sqa2; -- fails in both
select * from t1, lateral (select * from t2, (select * from t3 where k = 3) sqa1) sqa2; -- works in both
```

Additionally, further nesting of lateral joins could bring about more issues.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.