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
Commit 72cd4e7
Browse filesBrowse the repository at this point in the historyBrowse files
fix(sql): re-qualify derived-table output so joins don't cross-product (#66)
A join over two derived tables (`FROM (SELECT …) a JOIN (SELECT …) b ON
a.k = b.k`) silently degenerated to a cross product: the `SubqueryAlias`
arm dropped the alias, so the derived output columns had no qualifier and
both `a.k`/`b.k` fell back to the first bare `k` (col 0) — `k = k`, always
true.
Fix: the derived-table arm now re-qualifies the inner projection's output
columns with the alias. A new optional `Project.qualifier` (L2 + L3) stamps
the alias onto each output column during schema derivation; the common case
(the SELECT list already lowered to a Projection) is retagged in place with
no extra node, and the `SELECT *` / non-Projection case is wrapped in an
identity re-qualifying projection built from the sub-plan's field names.
Verified: `(SELECT k,v FROM m) a JOIN (SELECT k,v FROM n) b ON a.k=b.k` now
lowers the predicate to `Column(0) = Column(2)` (distinct), not
`Column(0) = Column(0)`. Two regression tests added (explicit-columns +
`SELECT *`); existing derived-table + join tests unchanged. Full workspace
suite green; clippy --all-targets clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments