Skip to content

fix(plan): infer prepared ntile parameters - #26950

Merged
mergify[bot] merged 4 commits into
matrixorigin:mainfrom
iamlinjunhong:m-26867
Aug 12, 2026
Merged

mergify[bot] merged 4 commits into
matrixorigin:mainfrom
iamlinjunhong:m-26867

Conversation

@iamlinjunhong

Copy link
Copy Markdown
Contributor

Cast prepared NTILE bucket markers to int64 while retaining dynamic parameter metadata, and reject non-integer bucket arguments during planning.

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #26867

What this PR does / why we need it:

fix(plan): infer prepared ntile parameters

@iamlinjunhong
iamlinjunhong requested a review from a user August 11, 2026 03:02
@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 Aug 11, 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.

[P1] Reject NULL for a prepared NTILE bucket count

This patch makes NTILE(?) bind as a nullable INT64 cast, but NULL is not validated at execution. FillValuesOfParamsInPlan(..., []any{nil}) succeeds; then ntileWindowExec.Fill skips the bucket-value check for a null vector entry and immediately defaults the bucket count to 1. Therefore PREPARE ... NTILE(?) ...; SET @n = NULL; EXECUTE ... USING @n silently returns a one-bucket result instead of rejecting the invalid argument.

This is also inconsistent with the static path: NTILE(NULL) is rejected by the new integer-only function check. The existing executor test explicitly asserts null_bucket_defaults_to_1, while the new BVT covers only a positive value, so the end-to-end NULL boundary is currently missed.

Please reject NULL at runtime, update the executor expectation, and add a prepared EXECUTE-with-NULL regression.

@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 d6cbb3f with all checks terminal and green.

[P1] Reject NULL for a prepared NTILE bucket count.

NTILE(?) now binds through a nullable INT64 cast, but NULL reaches ntileWindowExec.Fill, skips validation, and is defaulted to one bucket. That silently succeeds while the new static NTILE(NULL) path is rejected by the integer-only function check.

Please reject NULL at execution, update the executor expectation, and add an actual prepared EXECUTE-with-NULL regression.

Cast prepared NTILE bucket markers to int64 while retaining dynamic parameter metadata, and reject non-integer bucket arguments during planning.

@LeftHandCold LeftHandCold left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed exact head 7d094d272d0fd200df3701bea10f0d898e8be3e7.

Deep-reviewed the prepared-parameter path from planner inference through per-execution plan copying, expression evaluation, and both NTILE executors. The previous NULL issue is fixed before executor state is mutated, with unit and actual PREPARE/EXECUTE regression coverage. The new integer-only planner check does not remove a previously successful non-integer path: those types were already rejected by the runtime executor. Signed/unsigned integer handling, partitions, bucket counts larger than row counts, repeated execution, result metadata, cleanup, and ordinary literal NTILE paths show no new correctness, performance, or regression blocker.

All current required checks are terminal and green.

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

Re-reviewed exact head 7d094d2. The previous NULL blocker is fixed across both NTILE execution paths: a NULL bucket count is rejected before group state is mutated, and the public PREPARE/EXECUTE regression now covers the boundary. The prepared parameter receives a stable INT64 computation context, ordinary non-integer NTILE arguments remain rejected, and protocol metadata is covered. Full owning-package build, vet, and tests passed for pkg/sql/plan, pkg/sql/colexec/aggexec, pkg/sql/colexec/window, and pkg/frontend. A synthetic merge with current main 41e51e7 was conflict-free and the same full package tests passed. No remaining merge-blocking issue found.

@XuPeng-SH
XuPeng-SH requested a review from aunjgr August 12, 2026 04:39

@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 7d094d2. The prior prepared NTILE NULL blocker is closed in both execution paths before group state is mutated, and the public PREPARE and EXECUTE regression covers the boundary. The parameter receives a stable INT64 computation context, ordinary non-integer arguments remain rejected, repeated execution keeps plan state isolated, and result metadata is covered.

I found no remaining blocker. All current CI checks are terminal and green.

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

mergify Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-12 05:37 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-08-12 07:22 UTC · at 1fc4428b634a44894d4f29761e2c5ba36b285977 · squash

This pull request spent 1 hour 45 minutes 22 seconds in the queue, including 58 minutes 46 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • 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)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

@mergify
mergify Bot merged commit 3bd2abe into matrixorigin:main Aug 12, 2026
26 of 27 checks passed
@mergify mergify Bot removed the queued label Aug 12, 2026
@iamlinjunhong
iamlinjunhong deleted the m-26867 branch August 23, 2026 17:13
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026

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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants