[Bug] atan2 does not normalize -0.0 the way Spark does
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
Línea de trabajo
La corrección está en SparkAtan2 en datafusion/spark/src/function/math/atan2.rs, donde los argumentos sin procesar se pasan directamente a f64::atan2; suma primero 0.0 a ambos operandos, como describe el issue. La expectativa que hay que cambiar está en datafusion/sqllogictest/test_files/spark/math/atan2.slt, línea 155, de -3.14159 a 3.141592653589793. Ejecuta ese archivo de sqllogictest y comprueba que atan2(0.0, -0.0) y atan2(-0.0, -0.0) coinciden con los resultados de Spark que informa el issue antes de terminar.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 9.5k
- Forks
- 2.5k
- Merge medio
- 4 d 16 h
- PR fusionados (30 d)
- 330
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/datafusion
-
bug help wanted unparser
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/datafusion#26316 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Deduplicate bucket computation in width_bucket_interval_mdn_exactPosiblemente ocupada @nightcityblade la tomó hace 3 días. Abiertoenhancement good first issue help wanted spark tech debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
apache/datafusion#26307 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Use the shared aggr_test_schema in CSV scan tests instead of a local copyPosiblemente ocupada @med9110 la tomó hace 3 días. Abiertocore enhancement good first issue help wanted tech debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
apache/datafusion#26306 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
gcd benchmarks pass number_rows: 0 for 100k-row inputsPosiblemente ocupada @med9110 la tomó hace 3 días. Abiertobug functions good first issue help wanted tech debt
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
apache/datafusion#26297 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Struct union type coercion takes field nullability from the wrong field when field order differsPosiblemente ocupada @med9110 la tomó hace 3 días. Abiertobug help wanted logical-expr tech debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
apache/datafusion#26296 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/datafusion
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[Bug] ComponentType classifies 0x8A8A-0xEAEA as GREASE; mls-extensions §7.5 makes them private useAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
The book has a Nix install section that chelis.ch lacks, and it names two of the three systemsAbiertoarea:ecosystem documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Chelis-Lang/chelis#3866 ·
Los mantenedores suelen responder en 1 día
-
[安卓Feature]: 数字键盘左侧符号区域大小优化Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
metasequoiaime/msime#8620 ·
Los mantenedores suelen responder en 1 día
-
agent-detection macos p2 triaged
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día