← Back to Pull requests

Fix signed and whitespace-padded NaN parsing #5568

Closed
unknown closed this pull request without merging on Dec 01, 2026 02:53 UTC
View on GitHub
unknown unknown commented on Nov 30, 2026 08:36 UTC
Author

Fixes #5535. Contributes to NVIDIA/cudf-spark#17074.

String-to-FLOAT/DOUBLE casts now accept +NaN and -NaN, matching Spark. Previously these valid inputs produced NULL with ANSI disabled and an input-format error with ANSI enabled. Signed noncanonical spellings such as +nAn remain invalid, while unsigned NaN remains case-insensitive.

The parser checks the exact spelling before consuming the token, handles NaN/sign splits across 32-byte parser windows, and checks whole-row consumption after trailing whitespace. Unsigned NaN with long surrounding whitespace also follows Spark's behavior. Numeric-parser state is preserved when the token is not NaN.

The new regression tests cover both output types and ANSI modes, all NaN case variants, surrounding whitespace/C0 controls, null propagation, repeated signs, invalid suffixes and trailing garbage. They include 981 valid-input rows and 270 invalid-input rows, with padding around the 32/64-byte boundaries.

Validation:

  • The new valid-input regression fails on the original JNI at +NaN; the invalid-input control passes.

  • A CPU/GPU probe of 165 whitespace-boundary inputs found 155 mismatches before the window correction; the complete matrix passes after it.

  • mvn package: passed; complete CastStringsTest: 82 passed, 0 failed, 0 skipped.

  • All 28 native CTest targets passed, including 127/127 CAST_STRING tests.

  • Spark 3.3.0/JDK 11 CPU-then-GPU validation: original five-token reproducer; 161 valid rows plus 165 whitespace-boundary rows with ANSI off and on; 270 invalid rows with ANSI off; and 48 ANSI error checks. FLOAT/DOUBLE results and error behavior match. Executed plans verify the casts in GpuProject over GpuRange; class-source checks verify the newly built JNI is loaded.

  • Spark validation used plugin revision 730ebf0b with its embedded JNI replaced by this build, matching its cuDF/JNI 27.02 dependency. All retained plugin entries were verified unchanged.

  • Repository pre-commit checks passed.
  • The additional spelling check runs only after recognizing NaN, and the extra warp vote is needed only for signed tokens. The boundary probe reads three bytes only when a token can straddle a parser window. There are no additional column passes or allocations. Performance was not benchmarked.

    AI assistance was used for investigation, implementation, review and validation.

    Diff: 297 lines (+222 / -75) across 3 files Reviewer: wjxiz1992 Review duration: 1097m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 297 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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
    Diff Size diff_size
    0.341
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5568"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 40% (MEDIUM) · Higher = larger blast radius
    40%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 15.8% · Safe to merge
    15.8%