refactor(window): consume explicitly sorted input#378
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feat/spill #378 +/- ##
==============================================
- Coverage 92.91% 92.90% -0.01%
==============================================
Files 253 253
Lines 43141 43190 +49
==============================================
+ Hits 40084 40126 +42
- Misses 3057 3064 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue link:
Window execution currently performs its own in-memory sort and materializes the full input. This couples Window to one sorting implementation and prevents the existing spill-backed ExternalSort from satisfying Window ordering.
What is changed and how it works?
Window now consumes explicitly sorted input instead of sorting internally. The binder inserts a Sort on
PARTITION BY + ORDER BY; native builds with thespillfeature therefore use the existing ExternalSort executor, while non-spill and WASM builds continue to use the in-memory Sort implementation.The Window executor processes ordered input incrementally and retains only the rows required by the current function set: one row, one peer group, or one partition. Partition and peer boundaries are detected from cached sort values, and a single pending row carries a boundary across buffered output.
Code changes
Check List
Tests
Window unit coverage verifies row-, peer-, and partition-retention behavior. SQL logic coverage verifies ranking, aggregate windows, multiple window groups, partition boundaries, peer ties, views, and explain output. The spill-enabled build also compiles successfully.
Side effects
Note for reviewer
The primary goal is to decouple Window from Sort. Window only requires ordered input; with
spillenabled, the existing Sort execution path selects ExternalSort and provides spill support without adding spill-specific code to Window.The repository-wide clippy target remains blocked by pre-existing warnings outside this change: an unused parser import, unused optimizer pattern/matcher code, and
manual_is_multiple_ofin the existing ExternalSort test.