Skip to content

fix(optimizer): do not hoist subqueries across anonymous function boundaries - #8884

Merged
georgesittas merged 1 commit into
mainfrom
trey/no-hoist-anon
Nov 4, 2026
Merged

georgesittas merged 1 commit into
mainfrom
trey/no-hoist-anon

Conversation

@treysp

@treysp treysp commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

SQLGlot can move a child subquery into a join before establishing whether the surrounding anonymous function is scalar or aggregate.

For aggregates SQLGlot does not recognize, this can produce invalid SQL: either a joined column outside aggregation or a MAX(...) nested inside another aggregate.

With this PR, sqlglot will not move a child through an anonymous function, even when the parent has explicit grouping.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

SQLGlot Integration Test Results

✅ All tests passed

Comparing:

  • this branch (sqlglot:trey/no-hoist-anon @ sqlglot 12de63a)
  • baseline (main @ sqlglot 2fe2529)

Overall

main: 182929 total, 166022 passed (pass rate: 90.8%)

sqlglot:trey/no-hoist-anon: 182929 total, 166022 passed (pass rate: 90.8%)

Transitions:
No change

✅ All tests passed

@georgesittas
georgesittas merged commit bd21922 into main Nov 4, 2026
9 checks passed
@georgesittas
georgesittas deleted the trey/no-hoist-anon branch November 4, 2026 11:28
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.

2 participants