← Back to Pull requests

fix: align extreme decimal scales safely for addition and subtraction #7811

Open
unknown opened this pull request with 159 lines diff across 1 files
View on GitHub
unknown unknown commented on Dec 01, 2026 05:06 UTC
Author

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.

  • Multiplication and remainder are unchanged. No new dependency or configuration is needed.
  • 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_add and try_subtract at scale -128. Tests are delegated to fork CI. No tests were run locally.

    Diff: 159 lines (+119 / -40) across 1 files Reviewer: comphead Review duration: 2488m
    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
    0.33
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 33.4% (LOW) · Higher = larger blast radius
    33.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19% · Safe to merge
    19%