Skip to content

fix(plan): resolve prepared numeric expression types - #25788

Merged
XuPeng-SH merged 15 commits into
matrixorigin:mainfrom
ck89119:issue-25751-main
Jul 17, 2026
Merged

XuPeng-SH merged 15 commits into
matrixorigin:mainfrom
ck89119:issue-25751-main

Conversation

@ck89119

@ck89119 ck89119 commented Jul 16, 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:

issue #25751

What this PR does / why we need it:

  • Add an arithmetic-specific numeric resolver for prepared expressions.
  • Infer parameter types from approximate operands, decimal operands, exact outer context, integer operands, or the default
    DOUBLE domain.
  • Propagate numeric context through nested arithmetic, casts, unary operators, columns, and MOD while isolating unrelated
    functions, comparisons, and temporal expressions.
  • Keep ParamRef transport as TEXT and materialize the computation type through explicit casts.
  • Cover all supported arithmetic operators, decimal result metadata, context boundaries, and GROUP BY/alias state
    preservation.

Validation:

  • go test ./pkg/sql/plan/function ./pkg/sql/plan -count=1
  • go vet ./pkg/sql/plan/function ./pkg/sql/plan
  • go build ./pkg/sql/plan/function ./pkg/sql/plan
  • Modified resolver coverage: 75%-100%; binder integration: 85.7%.
  • git diff --check

@ck89119
ck89119 requested review from XuPeng-SH and aunjgr as code owners July 16, 2026 03:36
@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 →

@ck89119
ck89119 requested a review from XuPeng-SH July 17, 2026 08:47

@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 after re-reviewing current head fffa28e on latest main.

The previously confirmed temporal-subtraction blocker is closed. Numeric AST admission now rejects non-numeric typed operands and falls back to the legacy coercion path; DATE and DATETIME are covered with the prepared parameter on both sides.

Reviewed closure:

  • numeric precedence: approximate > decimal > exact outer context > integer > default DOUBLE
  • explicit parameter casts preserve the TEXT transport contract
  • comparison, unrelated-function, direct-cast, and temporal boundaries remain isolated
  • MOD, unary operators, all binary arithmetic operators, BIT capacity, decimal width/scale, correlated lookup, and binder group/alias state are covered
  • temporary binder numeric context is restored on success/error/boundary paths; no new resource, wait, or unbounded-retention edge

Local deterministic validation:

  • focused resolver and binder regression suites: count=5
  • full pkg/sql/plan/function and pkg/sql/plan tests
  • dependent pkg/sql/compile tests
  • compile-only checks and go vet for all three packages

All passed; no blocking correctness or unhappy-path finding remains.

@mergify mergify Bot added the queued label Jul 17, 2026
@mergify

mergify Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-17 09:26 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-07-17 10:49 UTC · at b0572ebfcca673ddfe267d41f01f31413a7edd66

This pull request spent 1 hour 22 minutes 44 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of: [🛡 GitHub branch protection]
    • 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)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • 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 Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • 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
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • 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)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • 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 Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • 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
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection] (documentation)
  • github-review-decision = APPROVED [🛡 GitHub branch protection] (documentation)

Reason

Pull request #25788 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 96847b5 into matrixorigin:main Jul 17, 2026
20 of 21 checks passed
@mergify mergify Bot added dequeued and removed queued labels Jul 17, 2026
@ck89119
ck89119 deleted the issue-25751-main branch July 17, 2026 14:05

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 kind/refactor Code refactor size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants