[Bug] atan2 does not normalize -0.0 the way Spark does
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
La correzione si trova in SparkAtan2 in datafusion/spark/src/function/math/atan2.rs, dove gli argomenti grezzi vengono passati direttamente a f64::atan2; aggiungi prima 0.0 a entrambi gli operandi, come descritto nell'issue. L'aspettativa da modificare si trova in datafusion/sqllogictest/test_files/spark/math/atan2.slt alla riga 155, da -3.14159 a 3.141592653589793. Esegui quel file sqllogictest e verifica che atan2(0.0, -0.0) e atan2(-0.0, -0.0) corrispondano ai risultati di Spark riportati nell'issue prima di concludere.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
SparkAtan2 passes the raw arguments to Rust's f64::atan2 (atan2.rs#L82). Spark's Atan2 adds 0.0 to both arguments first, which turns a negative zero into a positive zero (mathExpressions.scala#L1229-L1237). The Spark source explains why: "With codegen, the values returned by -0.0 and 0.0 are different. Handled with +0.0".
So atan2 returns a different value whenever y or x is -0.0.
To Reproduce
Spark 4.0.0:
SELECT atan2(CAST('-0.0' AS DOUBLE), -1.0D)
-- 3.141592653589793
SELECT atan2(0.0D, CAST('-0.0' AS DOUBLE))
-- 0.0
SELECT atan2(CAST('-0.0' AS DOUBLE), CAST('-0.0' AS DOUBLE))
-- 0.0
DataFusion: the existing test at atan2.slt#L155 documents the C99 result:
query R
SELECT atan2(-0.0::double, -1.0::double)
----
-3.141592653589793
The other two inputs were not run on DataFusion. By the C99 definition that Rust follows, atan2(0.0, -0.0) is pi and atan2(-0.0, -0.0) is -pi.
Expected behavior
Add 0.0 to both arguments before calling atan2, as Spark does, and change the expectation at atan2.slt#L155 to 3.141592653589793.
Additional context
Found by running the queries in datafusion/sqllogictest/test_files/spark on a local Spark and comparing the results with the expected values in the files, which is the kind of check proposed in #17045. Spark results come from Apple's build of Spark 4.0.0 (4.0.0.65-apple) with a UTC session and spark.sql.ansi.enabled=false unless stated. The Spark source links point at the v4.0.0 tag. DataFusion results are the sqllogictest expectations at 9dec77584, which CI enforces. Anything marked as not run was derived from reading the code.
- Lingua principale
- Rust
- Stelle
- 9.5k
- Fork
- 2.5k
- Merge medio
- 4g 16h
- PR unite (30g)
- 330
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un 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
-
bug help wanted unparser
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/datafusion#26316 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Deduplicate bucket computation in width_bucket_interval_mdn_exactForse già presa @nightcityblade l’ha presa 3 giorni fa. Apertaenhancement good first issue help wanted spark tech debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
apache/datafusion#26307 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Use the shared aggr_test_schema in CSV scan tests instead of a local copyForse già presa @med9110 l’ha presa 3 giorni fa. Apertacore enhancement good first issue help wanted tech debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
apache/datafusion#26306 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
gcd benchmarks pass number_rows: 0 for 100k-row inputsForse già presa @med9110 l’ha presa 3 giorni fa. Apertabug functions good first issue help wanted tech debt
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
apache/datafusion#26297 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Struct union type coercion takes field nullability from the wrong field when field order differsForse già presa @med9110 l’ha presa 3 giorni fa. Apertabug help wanted logical-expr tech debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
apache/datafusion#26296 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/datafusion
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
bherbruck/solvecraft#2167 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bitcoindevkit/bdk-cli#357 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
Wavvon/Wavvon-clients#136 ·
I maintainer di solito rispondono entro 1 giorno
-
GUI:纯报告任务验收后误显示“已合并”Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
vorton-lang/Lobotomy#95 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
AimesSoft/NipaPlay-Reload#1022 ·
I maintainer di solito rispondono entro 1 giorno