← Back to Pull requests

fix(spark): return NULL from parse_url for a key with a part other than QUERY #432

Open
unknown opened this pull request with 273 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 30, 2026 15:54 UTC
Author

Which issue does this PR close?

  • Closes #409.
  • Rationale for this change

    With a third key argument, parse_url('http://spark.apache.org/path?query=1', 'HOST', 'query') returned spark.apache.org, where Spark returns NULL. Spark only uses the key with QUERY and returns NULL for every other part. try_parse_url had the same problem.

    What changes are included in this PR?

    An early return in ParseUrl::parse when a key is given and the part is not QUERY. As in Spark, this check comes before the URL is parsed, so an invalid URL with a key and a non-QUERY part returns NULL instead of an error, even in ANSI mode (as requested on the issue). try_parse_url goes through the same function, so it is fixed too.

    Are these changes tested?

    Yes, with new cases in url/parse_url.slt and url/try_parse_url.slt: every non-QUERY part with a key, absolute and schemeless URLs, scalar and column inputs, and an invalid URL in ANSI mode (NULL for HOST, still an error for QUERY). The new cases fail without the fix. The full sqllogictest suite, cargo test -p datafusion-spark --all-features, cargo clippy --all-targets --all-features --workspace -- -D warnings and cargo fmt --check pass.

    Expected results were checked on Spark 4.2.0 with the PySpark runner (crates/sqllogictest/scripts/pyspark_slt_runner.py): all records in both files match, apart from the two existing xfail records. The Spark source agrees: Spark 4.2.0 returns null before parsing when the part is not QUERY (UrlExpressionEvalUtils.scala L77), and Spark 3.5.8 has the same check (urlExpressions.scala L279).

    This change also applies cleanly on top of #390, with the parse_url tests passing.

    Are there any user-facing changes?

    Yes: parse_url and try_parse_url with a key now return NULL for parts other than QUERY, matching Spark. No API changes.

    Diff: 273 lines (+204 / -69) across 3 files Reviewer: andygrove Review duration: 1636m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 273 lines diff across 3 files
    0.40
    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.336
    Real PR Conversation Timeline
    1 comments
    "Review active on #432"
    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: 39.5% (MEDIUM) · Higher = larger blast radius
    39.5%
    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: 21.1% · Safe to merge
    21.1%