andygrove opened a new issue, #358:
URL: https://github.com/apache/datafusion-spark/issues/358

   ### Describe the bug
   
   `expm1` calls Rust's `f64::exp_m1`, which uses the platform's C math 
library, so its result depends on the platform. On macOS, `expm1(1)` returns a 
different value from Spark's, and `math/expm1.slt` fails. It passes on Linux in 
CI.
   
   Spark's `Expm1` uses Java's `StrictMath.expm1`, which is fdlibm. Its result 
is 1 ulp below the correctly rounded value of e - 1, and macOS returns the 
correctly rounded value:
   
   | | `expm1(1)` |
   |---|---|
   | Spark 4.2.0 | `1.718281828459045` |
   | datafusion-spark on Linux (glibc) | `1.718281828459045` |
   | datafusion-spark on macOS | `1.7182818284590453` |
   
   ### To Reproduce
   
   On macOS:
   
   ```shell
   cargo test -p datafusion-spark-sqllogictest --test sqllogictests -- expm1
   ```
   
   ```
   [SQL] SELECT expm1(1::INT);
   [Diff] (-expected|+actual)
   -   1.718281828459045
   +   1.7182818284590453
   ```
   
   ### Expected behavior
   
   The same result as Spark on every platform. The `libm` crate is a port of 
musl's math library, which comes from fdlibm, and its `libm::expm1(1.0)` 
returns `1.718281828459045`. It matches `f64::exp_m1` on macOS for the other 
inputs I tried (`0.5`, `-1`, `1e-10`, `10`). `libm` is already in `Cargo.lock` 
as a transitive dependency.
   
   ### Additional context
   
   Other math functions that call the platform's math library, rather than one 
that matches `StrictMath`, could differ from Spark in the same way. 
`math/expm1.slt` is the only `.slt` file that fails on macOS today.
   


-- 
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]

Reply via email to