fix(spark): return NULL from parse_url for a key with a part other than QUERY #432
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
andygrove
Which issue does this PR close?
Rationale for this change
With a third
keyargument,parse_url('http://spark.apache.org/path?query=1', 'HOST', 'query')returnedspark.apache.org, where Spark returnsNULL. Spark only uses the key withQUERYand returnsNULLfor every other part.try_parse_urlhad the same problem.What changes are included in this PR?
An early return in
ParseUrl::parsewhen a key is given and the part is notQUERY. As in Spark, this check comes before the URL is parsed, so an invalid URL with a key and a non-QUERYpart returnsNULLinstead of an error, even in ANSI mode (as requested on the issue).try_parse_urlgoes through the same function, so it is fixed too.Are these changes tested?
Yes, with new cases in
url/parse_url.sltandurl/try_parse_url.slt: every non-QUERYpart with a key, absolute and schemeless URLs, scalar and column inputs, and an invalid URL in ANSI mode (NULLforHOST, still an error forQUERY). 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 warningsandcargo fmt --checkpass.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 existingxfailrecords. The Spark source agrees: Spark 4.2.0 returnsnullbefore parsing when the part is notQUERY(UrlExpressionEvalUtils.scalaL77), and Spark 3.5.8 has the same check (urlExpressions.scalaL279).This change also applies cleanly on top of #390, with the
parse_urltests passing.Are there any user-facing changes?
Yes:
parse_urlandtry_parse_urlwith a key now returnNULLfor parts other thanQUERY, matching Spark. No API changes.