Skip to content

fix(decimal): avoid DECIMAL256 MOD/DIV scale overflow - #28804

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/issues-28789-28790-decimal-scale-arithmetic
Sep 13, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/issues-28789-28790-decimal-scale-arithmetic

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

Summary

Fixes #28789
Fixes #28790

Validation

  • Focused DECIMAL256 MOD/DIV UTs passed.
  • Full pkg/container/types and pkg/sql/plan/function suites passed.
  • git diff --check passed.
  • Distributed BVT SQL added but not run locally because the configured tester endpoint would use the shared service.

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

Choose a reason for hiding this comment

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

GPT-6 medium deep review at head 707ff981393087952cb26270c3c46d10dd5f6c57: no blockers found. Reviewed MOD/DIV scale handling, error preservation, sign restoration, truncation, BIGINT boundaries, NULL/zero cases, and bounded big.Int fallbacks. Exact-head PROXY CI ran dtype/decimal_256.test: 12/12 passed.

VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8804)

## Summary
- Compute exact MOD remainders without materializing an overflowing
scale-aligned coefficient.
- For DIV, truncate the numerator for negative scale adjustments and use
a bounded exact quotient fallback when positive scaling overflows.
- Preserve sign, null/zero handling, truncation, and final BIGINT
overflow behavior.
- Add unit and distributed regression coverage for matrixorigin#28789 and matrixorigin#28790.

Fixes matrixorigin#28789
Fixes matrixorigin#28790

## Validation
- Focused DECIMAL256 MOD/DIV UTs passed.
- Full pkg/container/types and pkg/sql/plan/function suites passed.
- git diff --check passed.
- Distributed BVT SQL added but not run locally because the configured
tester endpoint would use the shared service.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8804)

## Summary
- Compute exact MOD remainders without materializing an overflowing
scale-aligned coefficient.
- For DIV, truncate the numerator for negative scale adjustments and use
a bounded exact quotient fallback when positive scaling overflows.
- Preserve sign, null/zero handling, truncation, and final BIGINT
overflow behavior.
- Add unit and distributed regression coverage for matrixorigin#28789 and matrixorigin#28790.

Fixes matrixorigin#28789
Fixes matrixorigin#28790

## Validation
- Focused DECIMAL256 MOD/DIV UTs passed.
- Full pkg/container/types and pkg/sql/plan/function suites passed.
- git diff --check passed.
- Distributed BVT SQL added but not run locally because the configured
tester endpoint would use the shared service.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8804)

## Summary
- Compute exact MOD remainders without materializing an overflowing
scale-aligned coefficient.
- For DIV, truncate the numerator for negative scale adjustments and use
a bounded exact quotient fallback when positive scaling overflows.
- Preserve sign, null/zero handling, truncation, and final BIGINT
overflow behavior.
- Add unit and distributed regression coverage for matrixorigin#28789 and matrixorigin#28790.

Fixes matrixorigin#28789
Fixes matrixorigin#28790

## Validation
- Focused DECIMAL256 MOD/DIV UTs passed.
- Full pkg/container/types and pkg/sql/plan/function suites passed.
- git diff --check passed.
- Distributed BVT SQL added but not run locally because the configured
tester endpoint would use the shared service.

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

2 participants