Repository navigation
Conversation
…in#23969) processOrder was clearing ctr.ps at the end, causing processValueFunc to treat all rows as a single partition. Remove the erroneous ctr.ps = nil since cleanup is already handled in processFunc.
There was a problem hiding this comment.
Pull request overview
Fixes an execution-order bug in the window operator where LAG/LEAD/FIRST_VALUE/LAST_VALUE/NTH_VALUE could lose PARTITION BY boundaries after sorting, causing all rows to be treated as one partition.
Changes:
- Stop clearing
ctr.ps(partition boundaries) at the end ofprocessOrder, so value window functions can still read partition info. - Add distributed SQL test cases covering lag/lead offsets, defaults, and
PARTITION BY + ORDER BY. - Update expected results to include the new test outputs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pkg/sql/colexec/window/window.go |
Preserves partition boundary state across processOrder → value window function evaluation. |
test/distributed/cases/window/value_window_functions.sql |
Adds regression tests reproducing the lag/lead partition bug. |
test/distributed/cases/window/value_window_functions.result |
Updates golden outputs for the new regression coverage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1 task done
This branch was previously deployed
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 type of PR is this?
Which issue(s) does this PR fix?
Fixes #23969
What this PR does
Cherry-pick of #23971 to 3.0-dev.
processOrderwas clearingctr.ps(partition boundaries) at the end of the method. WhenprocessValueFunc(which handles lag/lead/first_value/last_value/nth_value) was called afterwards,ctr.pswas alreadynil, so all rows were treated as a single partition.The fix removes the erroneous
ctr.ps = nilat the end ofprocessOrder. The cleanup ofctr.psis already handled inprocessFuncafter the value function results are computed.