fix: align extreme decimal scales safely for addition and subtraction #7811
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.33) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 159 lines diff across 1 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.304
Real PR Conversation Timeline
1 comments
"Review active on #7811"
general
weight: 0.35
comphead
Which issue does this PR close?
Closes #7810.
Why are the changes needed?
Comet computes decimal width in i16, but Arrow's narrow add/subtract still evaluates precision minus scale in i8. At precision 3 and scale -125, that intermediate is 128. For operands with very different scales, Comet's wide kernel can also exceed the i256 power or coefficient limit before it checks the result.
What changes were proposed in this PR?
Use the existing wide native kernel when the integer-digit count exceeds 127. At precision 3, scale -124 stays on the narrow path.
Keep i256 when the aligned coefficients and rescaling factors fit the conservative 76-digit bound. Otherwise compute the operation exactly in BigInt, round once with HALF_UP and check the target precision. Overflow produces a Spark numeric error in ANSI mode and NULL in TRY or legacy mode.
How was this PR tested?
Added Rust tests for both planner boundaries, the 76/77-digit transition, signed rounding, ANSI error values, NULL inputs and overflow masking. Added a Spark integration test for native
try_addandtry_subtractat scale -128. Tests are delegated to fork CI. No tests were run locally.