Implement Spark-compatible `xpath_string`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
First check that the shared XML evaluator from the xpath issue (#271) exists under crates/spark/src/function/xml/; this function builds on it and is blocked without it. Port Spark's XPathString / UDFXPathUtil.evalString semantics — XPath 1.0 string() conversion and number formatting — into a new function there, adding #[user_doc]. Enable and extend the stub crates/sqllogictest/test_files/xml/xpath_string.slt with the cases listed; done when that suite passes against Spark's outputs.
索引モデルが issue の本文から書いたものです。
説明
Part of #271 and apache/datafusion-comet#7300.
What the function does
xpath_string(xml, path) evaluates an XPath 1.0 expression and converts the result with the XPath string()
rules (XPathConstants.STRING), giving a STRING. For a node-set this is the string value of the first node in
document order, and for an element that is the concatenation of all its descendant text. Both arguments are
strings (collation-aware from 4.0, and the result has the session default string type). path must be
foldable. The result is always nullable. Available since Spark 2.0.0.
Parsing, DTD and entity handling, namespaces, NULL handling, invalid-XML and invalid-path errors, and lazy path
compilation are shared with the family. They are specified in the xpath issue. This issue covers only the
string conversion.
Examples
SELECT xpath_string('<a><b>b</b><c>cc</c></a>','a/c');
-- cc
SELECT xpath_string('<a><b>bb</b><c>cc</c></a>', 'a');
-- bbcc
SELECT xpath_string('<a><b>bb</b><c>cc</c></a>', 'a/b');
-- bb
SELECT xpath_string('<a><b>bb</b><c>cc</c></a>', 'a/d');
-- (empty string)
SELECT xpath_string('<a><b>b1</b><b>b2</b></a>', '//b');
-- b1
SELECT xpath_string('<a><b>b1</b><b>b2</b></a>', 'a/b[1]');
-- b1
SELECT xpath_string('<a><b>b1</b><b>b2</b></a>', 'a/b[2]');
-- b2
SELECT xpath_string('<a><b>b1</b><b id="b_2">b2</b></a>', 'a/b[@id="b_2"]');
-- b2
These come from the ExpressionDescription, the Hive udf_xpath_string golden files run by
HiveCompatibilitySuite, and XPathExpressionSuite. UDFXPathUtilSuite also has these cases:
a/b[3]/text()givesb3;a/b[4]/text()(no match) gives'';a/b[2]/@kgivesfoo;- an external entity (
<!ENTITY embed SYSTEM "...">) expands to''.
Edge cases to test
- No match gives
'', not NULL (a/dabove). NULL comes only from a NULL or''argument. - Conversion rules from XPath 1.0
string():- an element gives its concatenated descendant text, including whitespace-only text nodes and CDATA;
- comment and processing-instruction text inside the element is not included;
- an attribute gives its value;
- a boolean gives
trueorfalse.
- Numbers are formatted the XPath 1.0 way, not with Java's
Double.toString. Integers have no decimal point
(sum(a/b)over1and2gives3), and the special values areNaN,Infinityand-Infinity.
Derive the outputs from the spec and confirm them against Spark, because the formatting of large and small
magnitudes differs between engines. - XPath string functions in the path:
concat,substring(1-based, with rounding rules),normalize-space,
translate,substring-before/after, andstring-length(which XPath counts in characters; check
supplementary code points). - Entity and character references (
&,😀) are decoded in the output. So is an internal DTD
entity. - A non-literal path gives
DATATYPE_MISMATCH.NON_FOLDABLE_INPUT. Malformed XML and an invalid path raise
runtime errors (see thexpathissue).
Differences across Spark versions
None found beyond the shared ones in the xpath issue. From 4.0 the result is the session default string
type rather than plain StringType.
Implementation notes
- Spark:
XPathStringinsql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/xml/xpath.scala.
It callsXPathStringEvaluator, which callsUDFXPathUtil.evalString. - DataFusion core has no equivalent.
- Build it on the shared evaluator from the
xpathissue incrates/spark/src/function/xml/. The existing
crates/sqllogictest/test_files/xml/xpath_string.sltis a commented-out stub that should be enabled and
extended. Document the function with#[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
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
apache/datafusion-spark#287 ·
メンテナーはふだん 1 日以内に返信
-
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 日以内に返信
apache/datafusion-spark の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
storytold/photocraft#15232 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
suhina-daw/suhina-daw#1477 ·
メンテナーはふだん 1 日以内に返信
-
parity priority: low ui
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
storytold/pdfcraft#7483 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
IngvarConsulting/unica#3097 ·
メンテナーはふだん 1 日以内に返信
-
enhancement in-progress
難易度 1/5 1時間未満 初心者へのやさしさ 64/100