andygrove opened a new issue, #343: URL: https://github.com/apache/datafusion-spark/issues/343
`pmod(-5.0::double, 2.5::double)` returns `0` here, and Spark 4.2.0 returns `-0.0`. Spark's generated code checks `if (remainder < 0)` ([arithmetic.scala L1147-L1155](https://github.com/apache/spark/blob/32f7299601108917fb01920a54e084595b7b3bf8/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala#L1147-L1155)). That check is false for `-0.0`, so Spark returns the remainder `-0.0` unchanged. `spark_pmod` detects a negative remainder with Arrow's `lt` ([modulus.rs L157](https://github.com/apache/datafusion-spark/blob/125600164aa825e2fe805887dfdb384d4182f2a8/crates/spark/src/function/math/modulus.rs#L157)). Arrow uses a total order for floats, where `-0.0 < 0.0`, so `spark_pmod` adds the divisor and returns `(-0.0 + 2.5) % 2.5 = 0`. The same applies to `Float32`. Reported by mbutrovich in #333, where `math/pmod.slt` records Spark's result as a commented-out query. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
