Skip to content

fix(window): support prepared RANGE frame parameters - #28065

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
iamlinjunhong:m-28022
Sep 3, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
iamlinjunhong:m-28022

Conversation

@iamlinjunhong

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #28022

What this PR does / why we need it:

fix(window): support prepared RANGE frame parameters

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Sep 3, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify mergify Bot added the queued label Sep 3, 2026
@mergify

mergify Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-03 13:43 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-03 13:55 UTC · at c55019b32ddebd7bec7802514dc25728d87620c6

This pull request spent 12 minutes 5 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull 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.

The author needs to enable "Allow edits from maintainers" on this pull request.

Failing checks:

Hint

You 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.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit d0ad796 into matrixorigin:main Sep 3, 2026
25 of 26 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 3, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
)

## 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>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
)

## 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>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
)

## 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>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants