Skip to content

Fix correlated subqueries in grouped selects - #2514

Merged
mathiasrw merged 2 commits into
AlaSQL:developfrom
pratyushsinghal7:issue-1106
Aug 19, 2026
Merged

mathiasrw merged 2 commits into
AlaSQL:developfrom
pratyushsinghal7:issue-1106

Conversation

@pratyushsinghal7

Copy link
Copy Markdown
Contributor

Fixes #1106

Summary

  • retain the first source-row scope for each group so correlated scalar subqueries can resolve outer table aliases
  • resolve plain selected columns from that source row while keeping aggregate and grouped expressions on group state
  • avoid overwriting non-grouped columns with missing group values
  • add regression coverage for the reported grouped correlated subquery

Testing

  • bun test --preload ./test/bun-setup.js ./test/test1106.js ./test/test1967.js ./test/test941.js ./test/test416.js (25 passed, 1 skipped)
  • full suite: 2189 passed, 213 skipped, 0 failed
  • prettier --check src/40select.js src/423groupby.js src/424select.js test/test1106.js
  • git diff --check

Comment thread src/40select.js Resolved
@mathiasrw

Copy link
Copy Markdown
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't reference table name in subquery if grouped

2 participants