Skip to content

Fix TOP scoping in set operations - #3213

Open
sanketpatel32 wants to merge 3 commits into
AlaSQL:mainfrom
sanketpatel32:devin/1796223269-top-set-operations
Open

sanketpatel32 wants to merge 3 commits into
AlaSQL:mainfrom
sanketpatel32:devin/1796223269-top-set-operations

Conversation

@sanketpatel32

Copy link
Copy Markdown

Thank you for the time you are putting into AlaSQL!

Fixes #3196

Summary

  • Compile TOP separately from a statement-level LIMIT when a SELECT in a set operation owns that TOP.
  • Apply the SELECT's own TOP before its rows are combined by UNION, UNION ALL, EXCEPT, or INTERSECT.
  • Preserve whole-result handling for trailing LIMIT/OFFSET/FETCH and the existing TOP with final ORDER BY behavior.
  • Add regression coverage for the issue examples, all four set operators, TOP PERCENT, parameterized TOP, trailing limits, and final ordering.

Verification

  • yarn test — 3081 passed, 0 failed
  • yarn test-format-all

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.

TOP of a SELECT in a set operation also limits the SELECTs after it

1 participant