Skip to content

fix(window): widen narrow integer RANGE frame bounds - #30973

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/cff2ab0c48817ffe6c0bd804b98a3a139bf269bd5329f8393ca5ea03dd8ce543
Oct 25, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/cff2ab0c48817ffe6c0bd804b98a3a139bf269bd5329f8393ca5ea03dd8ce543

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:

What this PR does / why we need it:

Numeric RANGE window frame bounds were folded into the physical type of narrow signed ORDER BY keys, so valid bounds such as 200 for TINYINT or 2147483648 for INT failed at plan time with an out-of-range error. This change keeps TINYINT, SMALLINT, and INT bounds in an int64 arithmetic domain, maps endpoints outside the physical key domain to the correct frame boundary, and preserves compatibility with older narrow bound literals.

Regression coverage includes planner type selection, ASC/DESC runtime boundaries for preceding/following frames, and SQL cases for TINYINT, SMALLINT, and INT bounds through INT64_MAX.

Validation: gofmt, git diff --check, and package resolution passed. Focused Go tests and end-to-end BVT execution remain pending because this worktree lacks the repository's CGo/native artifacts; compilation stops at the existing pkg/common/docfilter symbols C.mo_sorted64_build_fixed and C.mo_sorted64_free.

After the PR is merged, please ask the issue reporter to verify the six reported SQL cases.

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

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

Static review of the current head found no additional correctness issue in the widening path: narrow signed RANGE literals are carried as int64, then checked against the physical int8/int16/int32 domain before binary search; out-of-domain endpoints use the existing ASC/DESC insertion-boundary mapping. The added unit cases cover wide offsets in both sort directions and the BVT covers the reported TINYINT/SMALLINT/INT SQL forms. I have not independently executed tests. The only workflow run currently visible for this commit is Iceberg Connector E2E (success), which does not validate this window change; focused window tests and the window BVT still need executable CI evidence. I am leaving this as a comment review rather than approval until that evidence is available.

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

Commit review for exact head 2f954baf21490fe20d7f2f498d1f2c71a2a398a7 (new commit fix(window): return plan type for widened range bounds). The follow-up now returns the plan.Type expected by window bound folding (T_int64.ToType().PlanType()), matching rangeFrameBoundType's contract. Static inspection of the full change found the narrow signed paths widen the offset, perform checked int64 arithmetic, and map out-of-domain endpoints to the ASC/DESC boundary before narrowing for binary search; coverage includes int8/int16/int32, both order directions in executor tests, older narrow literal representations, and SQL cases through INT64_MAX. I found no new actionable defect. This is not an approval yet: exact-head UT, UT coverage, SCA, and shared build are still queued/in progress, and the only completed end-to-end check currently visible is unrelated Iceberg CI. I could not execute the focused tests locally because this workspace contains no MatrixOne checkout/runtime.

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

Incremental review for exact head 2676d67c6a3f3a50ee83b37cdb785b84f9a7a5b6 (test(window): cover widened prepared range bounds). This commit updates prepared-frame planner assertions from int32 to int64 and adds executor-level wide signed offset cases for int8/int16/int32 in both ASC and DESC order; I found no defect in this test-only delta. I could not execute tests locally because this workspace has no MatrixOne checkout/runtime. The exact-head GitHub checks currently show only Iceberg-related jobs (one tidy job succeeded; another was skipped), plus neutral Mergify checks; there is no window UT/BVT evidence yet, and commit status remains pending. Please run the focused window package tests and window_numeric_range_wide_bound BVT before treating this as validated.

@XuPeng-SH

XuPeng-SH commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 9d1f67f902ebfc66d73c8159636389411dd16753

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 9d1f67f902ebfc66d73c8159636389411dd16753

Assessment: approve

Reviewed all six changed files and their planner/executor consumers. Separating offset width from physical key width is coherent: checked arithmetic precedes narrowing, existing boundary searches remain authoritative, and older literal forms remain supported. No actionable defects found. Added runtime work is limited to scalar checks on affected RANGE frames.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

Validation:

  • Reused frozen exact-head successful UT, coverage, SCA, shared-build and both BVT results; reconciled package and window-case selection with repository CI scripts.

  • Independent SQL probe passed 24 scenario groups in 4.86s: three signed widths, ASC/DESC, four frame forms, literal/prepared execution, signed extremes, NULL peers, invalid bounds and recovery. Expected results used arbitrary-precision arithmetic.

  • Isolation preflight, native provenance with 192 matching inputs, formatting, whitespace and clean-source checks passed.

  • Receipts, logs, diagnostic overlay and hashes were audited and retained under /home/xupeng/.local/state/mo-bot/jobs/ea4d39b63b6cef26bce95706/attempt-1/check-audit.json.

Limitations:

  • Frozen CI evidence contains terminal check metadata, not raw per-case logs. The linked issue body was absent; review used the frozen PR contract and supplied regressions.

  • No performance benchmark was run; no speed improvement is claimed.

@mergify mergify Bot added the queued label Oct 24, 2026
@mergify

mergify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-24 22:12 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-25 02:15 UTC · at aed95be39eecc9da5d9715d13823861b1ee9d2af

This pull request spent 4 hours 3 minutes 27 seconds in the queue, with no time running CI.

Reason

Pull request #30973 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.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

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 9357a37 into matrixorigin:main Oct 25, 2026
26 of 27 checks passed
@mergify mergify Bot added dequeued and removed queued labels Oct 25, 2026
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 25, 2026
Fifth base update, resolving the DIRTY/CONFLICTING mergeability reported
against head a4a7ef9: upstream main advanced to 80ea60a three commits
past the merge-#4 base ac4ec31 (fix(window) matrixorigin#30973 widen narrow integer
RANGE frame bounds; fix(plan) matrixorigin#31015 overlapping ON DELETE CASCADE/SET NULL
order-independence; fix(frontend) matrixorigin#31052 preserve microseconds in session
timestamp overrides). merge-tree pinned a single content conflict,
pkg/sql/plan/window_binder_test.go, where matrixorigin#30973 appends
TestRangeFrameBoundTypeWidening (plus T_int32->T_int64 prepared-marker
assertion updates) at the same file tail this feature's
TestQuantileExactWeightedDistinctWindowBinding occupies.

Resolved semantically: both appended test functions are kept together with
upstream's widened marker assertions; window_binder.go and window.go
auto-merged this feature's DISTINCT window hook (bindWindowFuncExpr) beside
upstream's rangeFrameBoundType call site (bindWindowSpec) and this feature's
orderedSetWindowAggregate entry beside upstream's
signedNarrowRangeBound/signedRangeOffsetValue additions, all disjoint
regions. Upstream allocated no SQL function IDs in this range, so
QUANTILE_EXACT_WEIGHTED = 619 and FUNCTION_END_NUMBER = 620 stand; no
design decision, invariant, admission set or validation plan changed. The
upstream range touches no .github and no mo-tester content.

Validated by ladder v6 (mo-cgo-test): closure compile/link, the full aggexec
quantile matrix, function/registry id checks, the plan binder seam set now
including upstream's TestRangeFrameBoundTypeWidening and
TestPreparedWindowRangeFrameMarkers*, the window operator set now including
TestBuildRangeIntervalWideSignedBounds, the compile dispatch matrix and the
parser corpus - every step exit 0; gofmt, git diff --check and
git diff --cached --check clean. Logs preserved under
issue-29944/merge5-conflict-resolution/logs/.

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

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

3 participants