Implement Spark-compatible `xpath_number` (alias of `xpath_double`)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず crates/spark/src/function/xml/ にある既存の xpath_double UDF を読んでください — この issue は単なるエイリアスなので、開始する前にその UDF が登録されていることを確認してください。ScalarUDFImpl::aliases を通して xpath_number を追加し(Spark の FunctionRegistry にある expression[XPathDouble]("xpath_number", true) を反映)、#[user_doc] にエイリアスを記録してください。crates/sqllogictest/test_files/xml/xpath_double.slt(または新しい xpath_number.slt)に、2 つの例、NaN/0.0、xpath_number(xml, path) という列名、NULL 入力、折りたたみ不可のパスのエラーをカバーするケースを追加してください。完了とは、それらの slt ケースが通り、xpath_double の結果と完全に一致することを意味します。
索引モデルが issue の本文から書いたものです。
説明
Part of #271 and apache/datafusion-comet#7300.
What the function does
xpath_number(xml, path) is a registered alias of xpath_double: expression[XPathDouble]("xpath_number", true) in FunctionRegistry. It evaluates an XPath 1.0 expression, converts the result with XPath number(),
and returns DOUBLE. Both arguments are strings (collation-aware from 4.0), path must be foldable, and the
result is always nullable. Available since Spark 2.0.0. The only observable difference from xpath_double is
the display name: prettyName reads the FUNC_ALIAS tag, so the column header is xpath_number(...).
The numeric conversion rules (node-set, boolean and string to number, NaN, the empty node-set) are in the
xpath_double issue. Parsing, DTD and entity handling, namespaces, NULL handling and the error behavior are
in the xpath issue. This one only needs the alias.
Examples
SELECT xpath_number('<a><b>1</b><b>2</b></a>','sum(a/b)');
-- 3.0
SELECT xpath_number('<a><b>1.0</b><b>2.1</b></a>', 'sum(a/b)');
-- 3.1
The first comes from the Hive udf_xpath_double golden file (DESCRIBE FUNCTION EXTENDED xpath_number) and
the second from XPathFunctionsSuite.
Edge cases to test
- Run the same cases as
xpath_doubleand check that the results match exactly, includingNaNfor
non-numeric text and0.0for a false boolean expression. - The output column name is
xpath_number(xml, path), notxpath_double(...). NULLor''arguments give NULL. A non-literal path givesDATATYPE_MISMATCH.NON_FOLDABLE_INPUT.
Differences across Spark versions
None found. The alias has existed since 2.0.0.
Implementation notes
- Spark:
XPathDoubleinsql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/xml/xpath.scala,
registered asxpath_numberinsql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala. - DataFusion core has no equivalent.
- Implement it as an alias (
ScalarUDFImpl::aliases) of thexpath_doubleUDF in
crates/spark/src/function/xml/, rather than as a separate kernel. This can be done in the same PR as
xpath_double. - Tests: add
xpath_numbercases tocrates/sqllogictest/test_files/xml/xpath_double.slt, or put them in a
separatexpath_number.slt. Mention the alias in the#[user_doc].
This issue was generated by an LLM (Claude) from the Apache Spark source code and tests. Examples come from Spark's ExpressionDescription examples, test suites and .sql.out golden files, but please verify them against Spark before relying on them.
- 主要言語
- Rust
- スター
- 7
- フォーク
- 15
- 平均マージ
- 16時間 43分
- マージ済み PR(30日)
- 26
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion-spark のほかの issue
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
apache/datafusion-spark#266 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] make_dt_interval returns NULL for more than about 1.49 million days, Spark returns the interval対応中かも @Subodh-17 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/datafusion-spark#109 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 18/100
apache/datafusion-spark#299 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
apache/datafusion-spark#298 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
apache/datafusion-spark#297 ·
メンテナーはふだん 1 日以内に返信
apache/datafusion-spark の issue をすべて見る
似ている issue
-
comp-rbac
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ClickHouse/ClickHouse#131875 ·
メンテナーはふだん 1 日以内に返信
-
bug(python): read_transaction raises TypeError on a Rewrite with rewritten indices対応中かも @Borg93 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
lance-format/lance#11117 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
storytold/photocraft#15232 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
forge: fork preflight reads still send `requireCanonical: false`, which Rootstock rejects (-32603)対応中かも @Ynyesto が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
foundry-rs/foundry#18485 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
bondybondbond/rushcut#238 · コメント 1 件 ·