fix: widen decimal arithmetic to Decimal256 - #28629
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
aptend
left a comment
There was a problem hiding this comment.
Deep review of exact head ac9cee1 (merge-base 9a07655). I read the linked issue, the only issue comment, and checked all review/inline/thread history (there are no prior reviews or threads), then traced the complete six-file diff through overload selection, binder-inserted casts, Decimal128/256 kernels, comparison narrowing, affine SUM rewriting, and downstream published result types. The same-type 39/40-digit cases are correctly widened and the comparison/affine adaptations are directionally sound, but three uncovered boundaries remain blocking: mixed numeric operands still stay on Decimal128, explicit casted string literals can generate an invalid width<scale implicit cast, and products beyond the public 65-digit precision can escape inside a value tagged DECIMAL(65). Native dependencies were built. Full exact-head ./pkg/sql/plan and ./pkg/sql/plan/function tests pass, as do the changed focused tests under -race. Three review-only counterexamples reproduced the findings and were removed; git diff --check is clean.
|
Resolved the latest failing checks at head The diagnostics show no Decimal regression: coverage and both Compose/Standalone BVT jobs passed. The only failed producer was ordinary Ubuntu UT:
Fix:
Local validation passed:
A fresh CI run has been triggered by the push. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed the full current change at d8342a4 against main b349fea, linked issue #28584, and all earlier review findings/replies. No remaining concrete blocker found.
All three previous findings are closed: widening is derived from original decimal/signed/unsigned domains after coercion; syntax-explicit CAST remains a domain boundary and weak literals are canonicalized at the declared scale; Decimal256 +, -, and * now validate non-NULL result coefficients against the published precision. The literal lookup refinement is materialized as an actual argument cast, avoiding a dispatch-only type change. Comparison narrowing now checks integral capacity as well as scale.
Traced binder/result metadata, existing Decimal256 kernels, constant/vector/NULL/selection-mask handling, casts and CTAS consumers, and the affine SUM proof/cast-back path. Existing physical operator IDs and Decimal256 representation are reused, rather than changing a legacy overload's physical argument/result contract. Affine restoration remains behind its exact integer-range/cardinality proof. Wider plans deliberately decline Substrait export instead of silently truncating to its 38-digit domain; this is a real offload/performance tradeoff explicitly recorded by the changed tests. Narrow fitting paths remain available; widened execution pays bounded 32-byte vector/cast work and one precision-validation pass.
The accompanying TestWWConflict adjustment starts its budget after setup, bounds both channel waits, retains transaction error assertions, joins both workers, and preserves deferred hook restoration. It does not retry away an assertion failure or remove the conflict scenario.
Validation: source/diff and consumer reasoning; reviewed mixed-domain resolver, explicit-cast/exponent, 65/66-digit runtime, comparison/CTAS, affine and BVT oracles. Reused the author's current-head reported plan/function/substrait package, targeted race TestWWConflict and build results, plus earlier relevant decimal BVT evidence. No fresh native suite, SQL deployment, mixed-version run or benchmark was executed by this reviewer; CI was not awaited. The PR body's older failed-build fragments are not counted as passing evidence. Historical executors still retain their own pre-fix precision-error behavior until upgraded; no new wire/disk representation is introduced.
|
已确认 aptend 提出的三个 Decimal256 精度边界均已落实:mixed numeric coercion 后 widening、显式 DECIMAL cast/弱字面量 domain 处理、以及 Decimal256 结果 65 位精度校验;对应 threads 均已解决,XuPeng-SH 已在上一 head 批准。 本次已同步当前 upstream/main(23b20ea909),新 head 为 a2fb9b1。 验证:
请复审当前 head。 |
|
Synced the latest main at head 62c370f after main advanced during review. The Decimal256 precision constraints remain intact. Revalidated go test ./pkg/sql/plan ./pkg/sql/plan/function ./pkg/sql/plan/substrait -count=1 and make build; all pass. |
…metic-widen # Conflicts: # pkg/sql/plan/function/list_operator.go
|
Synced with the latest upstream main (6602ca0) and resolved the arithmetic cast-rule conflict.\n\nConflict resolution:\n- preserve main's arithmeticTypeCastRule1 behavior for BIT unsigned range\n- then apply widenedDecimalArithmeticInputs for DECIMAL +, -, and *\n\nLocal verification:\n- go test ./pkg/sql/plan ./pkg/sql/plan/function ./pkg/sql/plan/substrait -count=1\n- make build\n\nAll passed. The branch is no longer behind main and GitHub reports it as mergeable. New head: 3383f8c. |
|
Fixed the failing PESSIMISTIC Compose BVT check in Root cause:
Changes:
Local verification:
A new CI run has been triggered for head |
|
Follow-up fix pushed in The PROXY Compose
The Decimal256 value itself was not the parse failure. I removed the inter-query comments while retaining the exact widened result assertion. The other Ubuntu UT failure was
Also verified after synchronizing latest
New CI run: https://github.com/matrixorigin/matrixone/actions/runs/34674424886 |
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28584
What this PR does / why we need it: