Repository navigation
fix(agg): propagate decimal AVG overflow errors - #27869
Merged
Merged
Conversation
ck89119
marked this pull request as ready for review
August 30, 2026 10:22
ck89119
requested review from
LeftHandCold,
XuPeng-SH,
aptend and
aunjgr
as code owners
August 30, 2026 10:22
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? |
1 task done
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#27855 ## What this PR does / why we need it: Decimal AVG finalization discarded errors returned by decimal division and result-scale conversion. It could therefore publish wrapped low bits after a physical Decimal128 overflow. A result can also fit the physical Decimal128/256 storage while exceeding the declared `DECIMAL(width, scale)` coefficient range. This PR: - makes `decAvg` return division and scale-conversion errors instead of a partial value; - validates the final coefficient against the declared result precision (`-10^width < coefficient < 10^width`) before publishing it; - propagates errors through the generic and specialized Decimal64/Decimal128 DISTINCT and non-DISTINCT flush paths; - preserves existing results for representable AVG inputs; - adds focused positive, negative, DISTINCT, Decimal128, and Decimal256 regression coverage; - adds a self-contained SQL BVT for physical overflow, declared-precision overflow, and representable/NULL controls. Validation: - pre-fix exact-head tests reproduced successful publication at both Decimal128(38,12) and Decimal256(65,12) declared-precision boundaries; - `mo-cgo-test ./pkg/sql/colexec/aggexec`: PASS, 79.9% package statement coverage (`decAvg`: 81.5%; precision-bound helpers: 100%); - complete `mo-service` build: PASS; - `func_avg_decimal_boundary.test` with mo-tester normal comparison: 13/13 PASS twice on the same clean instance; - database teardown check after each BVT run: clean. --------- 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
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#27855 ## What this PR does / why we need it: Decimal AVG finalization discarded errors returned by decimal division and result-scale conversion. It could therefore publish wrapped low bits after a physical Decimal128 overflow. A result can also fit the physical Decimal128/256 storage while exceeding the declared `DECIMAL(width, scale)` coefficient range. This PR: - makes `decAvg` return division and scale-conversion errors instead of a partial value; - validates the final coefficient against the declared result precision (`-10^width < coefficient < 10^width`) before publishing it; - propagates errors through the generic and specialized Decimal64/Decimal128 DISTINCT and non-DISTINCT flush paths; - preserves existing results for representable AVG inputs; - adds focused positive, negative, DISTINCT, Decimal128, and Decimal256 regression coverage; - adds a self-contained SQL BVT for physical overflow, declared-precision overflow, and representable/NULL controls. Validation: - pre-fix exact-head tests reproduced successful publication at both Decimal128(38,12) and Decimal256(65,12) declared-precision boundaries; - `mo-cgo-test ./pkg/sql/colexec/aggexec`: PASS, 79.9% package statement coverage (`decAvg`: 81.5%; precision-bound helpers: 100%); - complete `mo-service` build: PASS; - `func_avg_decimal_boundary.test` with mo-tester normal comparison: 13/13 PASS twice on the same clean instance; - database teardown check after each BVT run: clean. --------- 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
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#27855 ## What this PR does / why we need it: Decimal AVG finalization discarded errors returned by decimal division and result-scale conversion. It could therefore publish wrapped low bits after a physical Decimal128 overflow. A result can also fit the physical Decimal128/256 storage while exceeding the declared `DECIMAL(width, scale)` coefficient range. This PR: - makes `decAvg` return division and scale-conversion errors instead of a partial value; - validates the final coefficient against the declared result precision (`-10^width < coefficient < 10^width`) before publishing it; - propagates errors through the generic and specialized Decimal64/Decimal128 DISTINCT and non-DISTINCT flush paths; - preserves existing results for representable AVG inputs; - adds focused positive, negative, DISTINCT, Decimal128, and Decimal256 regression coverage; - adds a self-contained SQL BVT for physical overflow, declared-precision overflow, and representable/NULL controls. Validation: - pre-fix exact-head tests reproduced successful publication at both Decimal128(38,12) and Decimal256(65,12) declared-precision boundaries; - `mo-cgo-test ./pkg/sql/colexec/aggexec`: PASS, 79.9% package statement coverage (`decAvg`: 81.5%; precision-bound helpers: 100%); - complete `mo-service` build: PASS; - `func_avg_decimal_boundary.test` with mo-tester normal comparison: 13/13 PASS twice on the same clean instance; - database teardown check after each BVT run: clean. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2 of 4 tasks
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #27855
What this PR does / why we need it:
Decimal AVG finalization discarded errors returned by decimal division and result-scale conversion. It could therefore publish wrapped low bits after a physical Decimal128 overflow. A result can also fit the physical Decimal128/256 storage while exceeding the declared
DECIMAL(width, scale)coefficient range.This PR:
decAvgreturn division and scale-conversion errors instead of a partial value;-10^width < coefficient < 10^width) before publishing it;Validation:
mo-cgo-test ./pkg/sql/colexec/aggexec: PASS, 79.9% package statement coverage (decAvg: 81.5%; precision-bound helpers: 100%);mo-servicebuild: PASS;func_avg_decimal_boundary.testwith mo-tester normal comparison: 13/13 PASS twice on the same clean instance;