← Back to Pull requests

fix: width_bucket places an infinite value outside the range #426

Open
unknown opened this pull request with 239 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 27, 2026 05:57 UTC
Author

<!--
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
-->

Which issue does this PR close?

  • Closes #424.
  • Rationale for this change

    width_bucket returns NULL when the value is Infinity or -Infinity. Spark returns num_buckets + 1 for Infinity and 0 for -Infinity, because WidthBucket.computeBucketNumber returns NULL only for a NaN value, and for a NaN or infinite min or max. An infinite value is handled by the normal below-min and above-max checks.

    What changes are included in this PR?

  • The Float64 kernel now returns NULL for a NaN value only, instead of for any value that is not finite. The bounds must still be finite.

  • The function documentation says so, and docs/functions/scalar/math.md is regenerated with dev/update_function_docs.sh.
  • Are these changes tested?

    Yes. math/width_bucket.slt has new cases for Infinity and -Infinity as the value, with min < max and min > max, and for an infinite min and max. Without the kernel change the infinite-value cases return NULL; with it the whole width_bucket.slt passes, both with and without simplify.

    The expected results are the ones in #424, which reports PySpark 4.2.0 and 3.5.9. I did not run Spark myself. I also ran cargo fmt --all, cargo clippy --all-targets --all-features -- -D warnings and cargo test -p datafusion-spark-sqllogictest.

    Are there any user-facing changes?

    Yes. width_bucket now returns Spark's result for an infinite value instead of NULL.

    ---

    AI assistance: this change was prepared with Claude Code.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01LjXwp6RG3FDtC4t3PqLCQs

    Diff: 239 lines (+179 / -60) across 2 files Reviewer: andygrove Review duration: 6553m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.37) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 239 lines diff across 2 files
    0.37
    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.328
    Real PR Conversation Timeline
    1 comments
    "Review active on #426"
    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: 37.2% (MEDIUM) · Higher = larger blast radius
    37.2%
    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: 21.2% · Safe to merge
    21.2%