[Bug] parse_url ignores the key for a part other than QUERY, Spark returns NULL

Aperta Adatta ai principianti
#409 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Aryan2210 ci sta già lavorando.

Dal 30/11/2026.

  • #432 di @Aryan2210 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
64/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust, sql
Ambito
databases

Direzione di ricerca

Leggi crates/spark/src/function/url/parse_url.rs, in particolare i rami QUERY a L87-L90 e L110-L113, più try_parse_url, che ripete lo stesso match. Poiché la PR aperta #390 sposta quel match in extract_url_part, controllala per prima così il fix finisce nel posto giusto invece di entrare in conflitto. Fatto significa che un terzo argomento key restituisce NULL per ogni parte diversa da QUERY; verificalo con le query dell'issue sotto il runner sqllogictest sia in modalità simplify sia in modalità evaluate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

With a third key argument, Spark's parse_url returns NULL unless the part is QUERY. datafusion-spark ignores the key for the other parts and returns the part itself.

The key is only read in the two QUERY arms: L87-L90 for schemeless URLs and L110-L113 otherwise. The other arms return their part whatever the key is. try_parse_url does the same.

To Reproduce
SELECT parse_url('http://spark.apache.org/path?query=1', 'HOST', 'query'),
       parse_url('http://spark.apache.org/path?query=1', 'PATH', 'query'),
       parse_url('http://spark.apache.org/path?query=1', 'PROTOCOL', 'query'),
       parse_url('http://spark.apache.org/path?query=1', 'QUERY', 'query');
SELECT parse_url('/path?query=1', 'PATH', 'query');
SELECT try_parse_url('http://spark.apache.org/path?query=1', 'HOST', 'query');

datafusion-spark returns:

spark.apache.org  /path  http  1
/path
spark.apache.org
Expected behavior

As in Spark:

NULL  NULL  NULL  1
NULL
NULL
Spark versions

Spark 4.0.0: ParseUrlEvaluator.evaluate with a key starts with if (path != QUERY) return null (UrlExpressionEvalUtils.scala#L77). Spark 3.5.0 has the same check (urlExpressions.scala#L279). Spark 4.0's try_parse_url is ParseUrl(children, failOnError = false) (urlExpressions.scala#L184), so the same check applies. Spark 3.5 has no try_parse_url. Not run on a live Spark.

datafusion-spark version

main at 2129f38

Additional context

Open PR #390 moves this match into extract_url_part. Found with the sqllogictest runner, in both simplify and evaluate modes.

cc @andygrove

Lingua principale
Rust
Stelle
13
Fork
31
Merge medio
2g 2h
PR unite (30g)
96

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/datafusion-spark

Tutte le issue di apache/datafusion-spark

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.