Implement Spark-compatible `xpath_number` (alias of `xpath_double`)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 70/100
Direzione di ricerca
Leggi prima l'UDF esistente xpath_double in crates/spark/src/function/xml/ — questa issue è solo un alias, quindi conferma che quell'UDF sia registrata prima di iniziare. Aggiungi xpath_number tramite ScalarUDFImpl::aliases (rispecchiando expression[XPathDouble]("xpath_number", true) nel FunctionRegistry di Spark) e annota l'alias nel #[user_doc]. Aggiungi casi a crates/sqllogictest/test_files/xml/xpath_double.slt (o a un nuovo xpath_number.slt) che coprano i due esempi, NaN/0.0, il nome della colonna xpath_number(xml, path), input NULL e l'errore di percorso non ripiegabile; fatto significa che quei casi slt passano e corrispondono esattamente ai risultati di xpath_double.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Rust
- Stelle
- 7
- Fork
- 15
- Merge medio
- 16h 43m
- PR unite (30g)
- 26
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/datafusion-spark
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
apache/datafusion-spark#266 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] make_dt_interval returns NULL for more than about 1.49 million days, Spark returns the intervalForse già presa @Subodh-17 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/datafusion-spark#109 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
apache/datafusion-spark#299 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
apache/datafusion-spark#298 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
apache/datafusion-spark#297 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/datafusion-spark
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
storytold/photocraft#15232 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
suhina-daw/suhina-daw#1477 ·
I maintainer di solito rispondono entro 1 giorno
-
parity priority: low ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
storytold/pdfcraft#7483 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
IngvarConsulting/unica#3097 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement in-progress
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 64/100