Skip to content

fix: support dynamic precision for ROUND and TRUNCATE - #28502

Merged
XuPeng-SH merged 8 commits into
matrixorigin:mainfrom
ck89119:issue-28492-main
Sep 9, 2026
Merged

XuPeng-SH merged 8 commits into
matrixorigin:mainfrom
ck89119:issue-28492-main

Conversation

@ck89119

@ck89119 ck89119 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

issue #28492

What this PR does / why we need it:

ROUND and TRUNCATE now evaluate a non-constant precision expression for each row and propagate NULL precision values as NULL, matching MySQL compatibility behavior. Constant precision keeps the existing fast path, while CEIL and FLOOR retain their constant-precision contract.

The change adds focused vector-function coverage for positive, zero, negative, and NULL precision values, and enables the existing SQL regression coverage for dynamic DECIMAL precision.

Validation

  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run 'TestRoundAndTruncateWithDynamicDigits|TestTruncate$' ./pkg/sql/plan/function
  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 ./pkg/sql/plan/function

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

Review 结论:APPROVE。

Exact head: 623daa4

旧 review 中的两个 blocker 已确认修复:

  • 动态 ROUND precision 现在在 zonemap 中保守返回未知范围,避免错误裁剪块。
  • 参数 frame 按需扩容,且新增测试覆盖同一 wrapper 的 const → NULL → flat → masked → const 状态切换。

当前未发现 confirmed blocker。非阻塞建议:补充 Decimal 极端 precision/整数边界、错误后复用、真实 Hive 分区表示切换及性能长尾验证。

未执行本地 Go UT/race、现场 SQL/Hive 反例、故障注入、性能及版本兼容矩阵。

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

mergify Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-09 13:47 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-09 14:30 UTC · at 181988824bbe982fe305f3c60f7b494ae4b198ef

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

Reason

The pull request can't be updated

This pull request seems to come 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, or update the branch manually.

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.

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 53c2aa2 into matrixorigin:main Sep 9, 2026
25 of 26 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 9, 2026
@ck89119
ck89119 deleted the issue-28492-main branch September 10, 2026 02:57
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8502)

## What type of PR is this?

- [x] BUG

## Which issue(s) this PR fixes:

issue matrixorigin#28492

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

ROUND and TRUNCATE now evaluate a non-constant precision expression for
each row and propagate NULL precision values as NULL, matching MySQL
compatibility behavior. Constant precision keeps the existing fast path,
while CEIL and FLOOR retain their constant-precision contract.

The change adds focused vector-function coverage for positive, zero,
negative, and NULL precision values, and enables the existing SQL
regression coverage for dynamic DECIMAL precision.

## Validation

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run
'TestRoundAndTruncateWithDynamicDigits|TestTruncate$'
./pkg/sql/plan/function`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1
./pkg/sql/plan/function`

---------

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
…8502)

## What type of PR is this?

- [x] BUG

## Which issue(s) this PR fixes:

issue matrixorigin#28492

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

ROUND and TRUNCATE now evaluate a non-constant precision expression for
each row and propagate NULL precision values as NULL, matching MySQL
compatibility behavior. Constant precision keeps the existing fast path,
while CEIL and FLOOR retain their constant-precision contract.

The change adds focused vector-function coverage for positive, zero,
negative, and NULL precision values, and enables the existing SQL
regression coverage for dynamic DECIMAL precision.

## Validation

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run
'TestRoundAndTruncateWithDynamicDigits|TestTruncate$'
./pkg/sql/plan/function`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1
./pkg/sql/plan/function`

---------

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
…8502)

## What type of PR is this?

- [x] BUG

## Which issue(s) this PR fixes:

issue matrixorigin#28492

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

ROUND and TRUNCATE now evaluate a non-constant precision expression for
each row and propagate NULL precision values as NULL, matching MySQL
compatibility behavior. Constant precision keeps the existing fast path,
while CEIL and FLOOR retain their constant-precision contract.

The change adds focused vector-function coverage for positive, zero,
negative, and NULL precision values, and enables the existing SQL
regression coverage for dynamic DECIMAL precision.

## Validation

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run
'TestRoundAndTruncateWithDynamicDigits|TestTruncate$'
./pkg/sql/plan/function`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1
./pkg/sql/plan/function`

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
mergify Bot pushed a commit that referenced this pull request Oct 9, 2026
…9765)

Adds current-main BVT coverage for row-dependent `TRUNCATE` precision with `DECIMAL(10,4)` input and an `INT` precision column, including both `d` and `d + 0`. The rows cover positive precision, a non-tie value that distinguishes truncation from rounding, negative precision, and NULL. An integer mismatch count asserts exact decimal values and NULL behavior because the BVT harness tolerates small decimal differences.

Main already supports runtime precision for `ROUND` and `TRUNCATE` from #28502; this PR adds the missing DECIMAL/INT regression coverage and makes no production-code changes.

Validation:

- `make -j8 build` on current main (with verified ONNX_PREBUILT_DIR set) (`dca6ffc2b`, Go 1.27.1 darwin/arm64): passed.
- BVT `func_math_dynamic_precision.test` on current main: 34/34 statements passed, 0 failed.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/sql/plan/function`: passed on `23d8f6125`; reused after the base update because the intervening source changes are outside this package's test dependency closure.

Approved by: @XuPeng-SH

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.

3 participants