Repository navigation
fix(window): support prepared RANGE frame parameters - #28065
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
43b92be to
8f7f6a8
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 8f7f6a86a8f3f1e6a07c48b222d88f20378f9eb5 against merge base ffc8d9f0625c76e87ba967984ce19db2d082b0ba.
Blocking finding:
[P1] Keep prepared RANGE correct at the smaller unsigned type boundaries.
This change admits a parameterized RANGE bound whenever the ORDER BY type is numeric, and validateRangeFrameBound explicitly accepts uint8, uint16, and uint32. The materialized parameter then enters searchLeftWithLocation / searchRightWithLocation as a literal of that exact type. Those three execution branches still compute col[rowIdx] + c directly, so the search key wraps at the type maximum. For example, with an ASC TINYINT UNSIGNED key containing 0, 250, RANGE BETWEEN CURRENT ROW AND ? FOLLOWING, and ? = 10, the conceptual upper boundary is 260 and must map to the partition end; the current code wraps it to 4 and binary-searches the wrong boundary, yielding a silent wrong frame/result. Their subtraction guard also uses value <= offset: equality is a valid zero boundary, not underflow, and the right-edge path can skip zero-valued peers by returning start immediately.
The arithmetic predates this PR, but this PR newly exposes it through the advertised prepared-RANGE support for all numeric ORDER BY types. BIT/uint64 and signed integers already use checked helpers plus outOfDomainRangeBoundary; please apply equivalent checked arithmetic to uint8/uint16/uint32 in both left and right searches, and add prepared SQL regressions for ASC/DESC PRECEDING/FOLLOWING at underflow, exact-zero, and overflow boundaries.
Outside that blocker, the per-Prepare materialization model, all-or-nothing runtime-frame publication, Reset/Free lifecycle, NULL/negative/non-finite validation, and ordinary numeric paths look sound. Parameter evaluation is once per execution rather than per row, so I found no hot-path performance or Q1-Q3 lifecycle blocker. Exact-head UT, SCA, BVT, and coverage checks are green.
8f7f6a8 to
1501845
Compare
aptend
left a comment
There was a problem hiding this comment.
Deep review of exact head 150184572495f2b67a536b9b9f263aa70999653f against exact PR base/merge-base 97a7f7f155a4042dc1e65d12599f18f91ad364d2. I read the complete PR, issue #28022, all review/comment history, and thread state (there are no inline threads), then audited the full six-file diff. I also range-diffed from the prior reviewed head 8f7f6a86a8f3f1e6a07c48b222d88f20378f9eb5; the only feature increment is the narrow-unsigned boundary fix.
The implementation is coherent: the binder continues to cast ROWS markers to uint64, casts numeric RANGE markers to the ORDER BY type, and still rejects temporal/interval parameter markers; Prepare materializes both bounds exactly once per execution, validates NULL/type/sign/finiteness, publishes runtime frames only after complete success, and clears them on Reset/Free. Runtime RANGE arithmetic now uses checked unsigned helpers for uint8/uint16/uint32 as well as uint64, correctly distinguishes above-domain overflow from below-domain underflow in ASC/DESC searches, and treats exact-zero subtraction as in-domain. Existing checked signed, float SQL ordering, decimal, temporal, peer/NULL, and partition-bound behavior remains intact. The prior reviewer counterexample is closed in both search directions and both sort orders.
Exact-head validation passed with the required CGO/thirdparties setup: full pkg/sql/colexec/window and pkg/sql/plan tests; focused prepared-frame and numeric-boundary race tests at count=10; go vet on both affected packages; and git diff --check. A review-only unsigned negative-parameter counterexample also passed by rejecting the value during cast/materialization, and was removed. SCA, coverage, proxy BVT, pessimistic multi-CN BVT, and the GitHub Summary are green; the broad Ubuntu UT job is still running but has not reported a failure. I found no blocking correctness, lifecycle, or compatibility issue.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head 1501845.
The previous unsigned RANGE blocker is resolved: uint8/uint16/uint32 arithmetic now uses width-aware checked bounds, exact-zero subtraction remains in-domain, and overflow/underflow is mapped to the correct insertion boundary for both ASC and DESC. Counterexample coverage includes PRECEDING/FOLLOWING, exact zero, and both domain ends. Prepared values are materialized once per execution, validation rejects NULL, negative, non-finite, and malformed values, and runtime state is published only after complete preparation.
I found no remaining correctness, performance, lifecycle, or unhappy-path blocker. Exact-head Linux UT, SCA, coverage, proxy BVT, and pessimistic multi-CN BVT are green.
Merge Queue Status
This pull request spent 12 minutes 5 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #28065 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Failing checks:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28022 ## What this PR does / why we need it: fix(window): support prepared RANGE frame parameters --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28022 ## What this PR does / why we need it: fix(window): support prepared RANGE frame parameters --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#28022 ## What this PR does / why we need it: fix(window): support prepared RANGE frame parameters --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
issue #28022
What this PR does / why we need it:
fix(window): support prepared RANGE frame parameters