Skip to content

fix(window): handle signed integer range bounds - #27578

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
Lundomn:fix/issue-27574-signed-window-range
Aug 25, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
Lundomn:fix/issue-27574-signed-window-range

Conversation

@Lundomn

@Lundomn Lundomn commented Aug 25, 2026

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:

Fixes #27574

What this PR does / why we need it:

Prevent signed integer RANGE frame boundary arithmetic from wrapping at the minimum and maximum values of TINYINT, SMALLINT, INT, and BIGINT. Out-of-domain search keys are now mapped to the correct insertion boundary for both ascending and descending order.

Add unit coverage for overflow, underflow, PRECEDING/FOLLOWING, and ASC/DESC behavior, plus a BVT covering all signed integer types, empty frames, and NULL peer groups.

Local validation:

  • Window package unit tests
  • Window package race tests
  • Window package go vet
  • Package coverage: 84.2%; changed statements: 52/52 (100%)
  • BVT expected-result comparison repeated 3 times
  • 500,010-row boundary validation repeated 2 times

@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 →

@aunjgr aunjgr 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 7d7d83980729e03e969f7b8c227544493ff3933c against merge base ae12701a888fac102e9641cc7cbb8706527366d8.

The helper detects both overflow directions for addition and subtraction without assuming a particular signed width, and its aboveDomain result maps to the correct insertion edge for ASC and DESC. I checked the complete frame mapping: ASC PRECEDING subtracts, ASC FOLLOWING adds, DESC PRECEDING adds, and DESC FOLLOWING subtracts, including zero offsets and MinInt negative-offset arithmetic. Search-left/search-right preserve their inclusive/exclusive contracts after an out-of-domain result. The tests cover every signed width, extrema, both sort directions, empty frames, and NULL peers with public SQL result oracles. No operator lifecycle, ownership, or wait path changes. I found no blocking 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.

Approved exact head 7d7d83980729e03e969f7b8c227544493ff3933c against merge base ae12701a888fac102e9641cc7cbb8706527366d8.

The new signedRangeBound detects addition and subtraction overflow for every signed width, including MinInt offsets, and outOfDomainRangeBoundary maps above/below-domain keys to the correct insertion edge for ASC and DESC. I checked the complete frame-direction mapping: ASC PRECEDING subtracts, ASC FOLLOWING adds, DESC PRECEDING adds, and DESC FOLLOWING subtracts; left remains inclusive and right remains exclusive.

I also ran an independent big.Int oracle over int8/int16/int32/int64, ASC/DESC, left/right searches, both arithmetic directions, five offsets, extrema, interior values, and duplicate peers. It passed normal and race runs 20 times each. The full window package passed normal and race tests; go vet, git diff --check, and formatting checks passed. The hot-path cost is constant comparisons only, with no allocation, logging, ownership, or lifecycle change. I found no blocking issue.

@mergify mergify Bot added the queued label Aug 25, 2026
@mergify

mergify Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-25 08:22 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-08-25 08:55 UTC · at 7d7d83980729e03e969f7b8c227544493ff3933c

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

Reason

The pull request can't be updated

merge conflict between base and head

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

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

Reviewed the full signed RANGE boundary change at the exact head. Verified the ASC/DESC and PRECEDING/FOLLOWING direction matrix, insertion-edge mapping, NULL/empty-frame behavior, and exhaustive int8 arithmetic against a wider integer oracle; all focused, race, vet, and diff checks passed. No blocking issues found.

@mergify mergify Bot added dequeued and removed queued labels Aug 25, 2026
@mergify

mergify Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-25 10:34 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-25 10:47 UTC · at 666f28fbec831dec9dd2b3e555ad46fa9d9eeb71

This pull request spent 13 minutes 32 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 #27578 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.

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 bc6c842 into matrixorigin:main Aug 25, 2026
17 of 19 checks passed
@mergify mergify Bot added dequeued and removed queued labels Aug 25, 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
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#27574

## What this PR does / why we need it:

Prevent signed integer RANGE frame boundary arithmetic from wrapping at
the minimum and maximum values of TINYINT, SMALLINT, INT, and BIGINT.
Out-of-domain search keys are now mapped to the correct insertion
boundary for both ascending and descending order.

Add unit coverage for overflow, underflow, PRECEDING/FOLLOWING, and
ASC/DESC behavior, plus a BVT covering all signed integer types, empty
frames, and NULL peer groups.

Local validation:
- Window package unit tests
- Window package race tests
- Window package go vet
- Package coverage: 84.2%; changed statements: 52/52 (100%)
- BVT expected-result comparison repeated 3 times
- 500,010-row boundary validation repeated 2 times

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
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#27574

## What this PR does / why we need it:

Prevent signed integer RANGE frame boundary arithmetic from wrapping at
the minimum and maximum values of TINYINT, SMALLINT, INT, and BIGINT.
Out-of-domain search keys are now mapped to the correct insertion
boundary for both ascending and descending order.

Add unit coverage for overflow, underflow, PRECEDING/FOLLOWING, and
ASC/DESC behavior, plus a BVT covering all signed integer types, empty
frames, and NULL peer groups.

Local validation:
- Window package unit tests
- Window package race tests
- Window package go vet
- Package coverage: 84.2%; changed statements: 52/52 (100%)
- BVT expected-result comparison repeated 3 times
- 500,010-row boundary validation repeated 2 times

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
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#27574

## What this PR does / why we need it:

Prevent signed integer RANGE frame boundary arithmetic from wrapping at
the minimum and maximum values of TINYINT, SMALLINT, INT, and BIGINT.
Out-of-domain search keys are now mapped to the correct insertion
boundary for both ascending and descending order.

Add unit coverage for overflow, underflow, PRECEDING/FOLLOWING, and
ASC/DESC behavior, plus a BVT covering all signed integer types, empty
frames, and NULL peer groups.

Local validation:
- Window package unit tests
- Window package race tests
- Window package go vet
- Package coverage: 84.2%; changed statements: 52/52 (100%)
- BVT expected-result comparison repeated 3 times
- 500,010-row boundary validation repeated 2 times

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

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: signed BIGINT Window RANGE bounds wrap at INT64 extrema and return empty frames

5 participants