← Back to Pull requests

Fix floating-point to decimal overflow before narrowing #5525

Open
unknown opened this pull request with 204 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 20, 2026 20:56 UTC
Author

Addresses NVIDIA/cudf-spark#16890.

The floating-point conversion narrowed the rounded coefficient to the destination integer type before checking decimal precision. An overflowing value could wrap into a valid-looking coefficient and pass the bounds check. For example, casting 43000000.0 to DECIMAL(9,2) returned 50327.04 instead of reporting overflow.

Keep the rounded magnitude unsigned until precision has been checked, then narrow it and apply the sign. An early input bound prevents overflow during the conversion itself, including the DECIMAL128 path. The bound is computed once per column to avoid unnecessary per-row scaling.

This also corrects the extra-rounding-digit safety check for negative scales and validates the supported scale and precision arguments. The Java API signatures are unchanged.

Validation

  • Added coverage for float/double overflow across all decimal storage widths, rounding carry, valid negative-scale conversions, nulls, nonfinite values and invalid arguments.

  • Built the 26.12.0-SNAPSHOT package against the release branch’s pinned cuDF revision.

  • Passed all 39 decimal Java tests and all 28 C++ test executables.
  • Performance

    A matched native microbenchmark of the identical conversion patch, run before retargeting to release/26.12, measured approximately 10–11% higher double-to-DECIMAL32 conversion latency, or 9–10 microseconds per million-row column. Double-to-DECIMAL64 differences were approximately 1–2%, within measurement variation.

    AI assistance was used for implementation and testing. The author reviewed and approved the complete changes before posting the PR.

    Diff: 204 lines (+153 / -51) across 2 files Reviewer: gerashegalov Review duration: 2823m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 204 lines diff across 2 files
    0.36
    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%
    46%
    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.318
    Real PR Conversation Timeline
    1 comments
    "Review active on #5525"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 36.3% (MEDIUM) · Higher = larger blast radius
    36.3%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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.4% · Safe to merge
    19.4%