Repository navigation
fix(window): handle uint64 range bounds - #27568
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? |
131ca9c to
a302725
Compare
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed exact head a3027255760850f891e6dad6be95abfe8c7588f8 against merge base 249a458ba567b26d1818fb0496b449135cb05ef2.
The fix correctly separates finite uint64 arithmetic from conceptual below/above-domain bounds and maps those bounds to the proper insertion edge for both ASC and DESC. I checked all four start/end PRECEDING/FOLLOWING direction combinations, equality at zero, addition overflow, subtraction underflow, NULL peer confinement, and the shared BIT representation. The unit and SQL regressions provide independent boundary/result coverage. I found no blocking issue.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head a3027255760850f891e6dad6be95abfe8c7588f8 against merge base 249a458ba567b26d1818fb0496b449135cb05ef2.
The fix closes #27565. uint64RangeBound computes addition/subtraction without wraparound, and outOfDomainRangeBoundary maps conceptual values below 0 or above MaxUint64 to the correct insertion boundary for both ASC and DESC. Using the same logic for BIT is correct because its stored comparison representation is uint64; a narrower BIT domain still maps an in-uint64 but out-of-column-domain target to the same end insertion point.
I checked the complete searchLeft/searchRight closure, peer and NULL handling, all valid PRECEDING/CURRENT/FOLLOWING combinations, zero offset, equality at zero, addition overflow, subtraction underflow, duplicates, and MaxUint64.
Independent validation:
- a temporary big.Int oracle exhaustively compared 2 types × 2 directions × 5 offsets × 6 frame shapes × 10 rows (including duplicates, 0, and MaxUint64); every computed [start,end) matched;
- the two new focused regressions and the independent oracle passed under race;
- the full
pkg/sql/colexec/windowpackage passed normally and under race; - go list/build/vet, gofmt, and diff checks passed;
- Q1-Q3: no new resource ownership, wait dependency, or accumulation; the added arithmetic is constant-time and allocation-free.
No blocking correctness, performance, or unhappy-path issue found.
Merge Queue Status
This pull request spent 59 minutes 27 seconds in the queue, including 59 minutes 5 seconds running CI. Required conditions to merge
|
aptend
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head abf111e640ceac189a3979f33ef5ef743be7f3ea against exact base ae12701a888fac102e9641cc7cbb8706527366d8, including the complete feature diff and all review history (2 prior approvals, no inline comments or review threads). The merge from main adds no feature delta beyond the reviewed uint64 RANGE fix.
The new arithmetic correctly distinguishes subtraction underflow from addition overflow, and maps conceptual below/above-domain keys to the correct insertion edge for ASC and DESC. The same handling is valid for BIT’s uint64 comparison representation; NULL peer confinement remains outside the changed arithmetic.
Independent validation: a temporary big.Int oracle compared both uint64/BIT, ASC/DESC, offsets 0/1/5/MaxUint64, five valid PRECEDING/CURRENT/FOLLOWING frame shapes, and rows containing duplicates, zero, and MaxUint64; every computed [start,end) matched. The temporary test was removed. Full window package tests, focused race tests (10x), vet, formatting, and diff checks passed. No blocking issue found.
Handle `BIGINT UNSIGNED` and `BIT` Window `RANGE` bounds without wrapping uint64 arithmetic or mapping out-of-domain bounds to the wrong ASC/DESC insertion boundary. This fixes low-key `RANGE ... FOLLOWING` frames that were incorrectly returned as empty and also covers subtraction underflow and addition overflow. Approved by: @aunjgr, @XuPeng-SH, @aptend
Handle `BIGINT UNSIGNED` and `BIT` Window `RANGE` bounds without wrapping uint64 arithmetic or mapping out-of-domain bounds to the wrong ASC/DESC insertion boundary. This fixes low-key `RANGE ... FOLLOWING` frames that were incorrectly returned as empty and also covers subtraction underflow and addition overflow. Approved by: @aunjgr, @XuPeng-SH, @aptend
Handle `BIGINT UNSIGNED` and `BIT` Window `RANGE` bounds without wrapping uint64 arithmetic or mapping out-of-domain bounds to the wrong ASC/DESC insertion boundary. This fixes low-key `RANGE ... FOLLOWING` frames that were incorrectly returned as empty and also covers subtraction underflow and addition overflow. Approved by: @aunjgr, @XuPeng-SH, @aptend
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #27565
What this PR does / why we need it:
Handle
BIGINT UNSIGNEDandBITWindowRANGEbounds without wrapping uint64 arithmetic or mapping out-of-domain bounds to the wrong ASC/DESC insertion boundary. This fixes low-keyRANGE ... FOLLOWINGframes that were incorrectly returned as empty and also covers subtraction underflow and addition overflow.Validation
go test ./pkg/sql/colexec/window/... -count=1go test -race ./pkg/sql/colexec/window/... -count=1go vet ./pkg/sql/colexec/window/...go test ./pkg/sql/colexec/... -count=1git diff --check origin/main...HEADpkg/sql/colexec/windowcoverage: 84.4%