[Bug] atan2 does not normalize -0.0 the way Spark does
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
調査の方向性
修正箇所は datafusion/spark/src/function/math/atan2.rs の SparkAtan2 です。ここでは未加工の引数がそのまま f64::atan2 に渡されています。issue に書かれているとおり、まず両方のオペランドに 0.0 を加えてください。変更すべき期待値は datafusion/sqllogictest/test_files/spark/math/atan2.slt の 155 行目にあり、-3.14159 から 3.141592653589793 に変更します。その sqllogictest ファイルを実行し、終了する前に atan2(0.0, -0.0) と atan2(-0.0, -0.0) が issue に記載された Spark の結果と一致することを確認してください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Rust
- スター
- 9.5k
- フォーク
- 2.5k
- 平均マージ
- 4日 19時間
- マージ済み PR(30日)
- 342
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion のほかの issue
-
bug help wanted unparser
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/datafusion#26316 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Deduplicate bucket computation in width_bucket_interval_mdn_exact対応中かも @nightcityblade が 2 日前に担当しました。 オープンenhancement good first issue help wanted spark tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
apache/datafusion#26307 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Use the shared aggr_test_schema in CSV scan tests instead of a local copy対応中かも @med9110 が 2 日前に担当しました。 オープンcore enhancement good first issue help wanted tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
apache/datafusion#26306 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
gcd benchmarks pass number_rows: 0 for 100k-row inputs対応中かも @med9110 が 2 日前に担当しました。 オープンbug functions good first issue help wanted tech debt
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
apache/datafusion#26297 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Struct union type coercion takes field nullability from the wrong field when field order differs対応中かも @med9110 が 2 日前に担当しました。 オープンbug help wanted logical-expr tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/datafusion#26296 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
apache/datafusion の issue をすべて見る
似ている issue
-
[1.x Bug] run-operation --sql reports success but rolls back writes on transaction-capable adaptersオープンtriage
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
dbt-labs/dbt#16784 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:cli bug good first issue priority:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
bnv-manager-v2: accept_invite creates the Mailcow domain admin before the commit対応中かも @myOmikron が今日担当しました。 オープンbug ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
platform:windows tool triaged wontfix
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
resources: add a regression test confirming admin mint still works after the #16 SAC handoff対応中かも @Daniexie が今日担当しました。 オープンcontracts good first issue Stellar Wave
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
OlaGreat/starbound-realms#137 · コメント 1 件 ·