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

未关闭 适合新手
#409 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@Aryan2210 已经在做这个了。

开始于 2026年11月30日。

  • #432 来自 @Aryan2210 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
64/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust, sql
领域
databases

调研方向

阅读 crates/spark/src/function/url/parse_url.rs,尤其是 L87-L90 和 L110-L113 处的 QUERY 分支,以及重复同一 match 的 try_parse_url。由于开放的 PR #390 会把该 match 移到 extract_url_part,请先检查它,以便修复落在正确的位置而不是产生冲突。完成意味着第三个 key 参数对除 QUERY 之外的每个部分都返回 NULL;请用 issue 中的查询在 sqllogictest runner 下以 simplify 和 evaluate 两种模式验证。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Rust
星标
13
派生
31
平均合并
2 天 2 小时
30 天内合并 PR
96

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/datafusion-spark 的其他 Issue

查看 apache/datafusion-spark 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。