Repository navigation
Conversation
Spark's Expm1 calls Java's StrictMath.expm1, which returns fdlibm's result. f64::exp_m1 calls the platform's C math library, which differs in the last bit on macOS. Use the libm crate, a port of musl's math library, which comes from fdlibm. Closes apache#358.
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
expm1result depends on the platform's math library and differs from Spark on macOS #358.Rationale for this change
expm1called Rust'sf64::exp_m1, which uses the platform's C math library. Spark'sExpm1calls Java'sStrictMath.expm1, which returns fdlibm's result on every platform. On macOS the results differ in the last bit for some inputs, andmath/expm1.sltfails:expm1(1)1.7182818284590451.7182818284590453expm1(-2.5D)-0.9179150013761013-0.9179150013761012expm1(0.9D)1.45960311115694991.4596031111569496expm1(1.7D)4.4739473917271994.4739473917272What changes are included in this PR?
expm1callslibm::expm1. Thelibmcrate is a pure Rust port of musl's math library, which comes from fdlibm, so it gives Spark's result on every platform.libmwas already inCargo.lockas a transitive dependency, and is now a direct dependency ofdatafusion-spark.Are these changes tested?
Yes. New records in
math/expm1.sltcover the three inputs above, small and large inputs, and overflow toInfinity. The existingexpm1(1)record and the new ones for-2.5,0.9and1.7fail on macOS without this change. I checkedexpm1.sltagainst Spark 4.2.0 with the PySpark runner, and every record matches. I also comparedlibm::expm1with Spark for 19 more inputs, including-0.0,NaNand both infinities, and every result matches.Are there any user-facing changes?
expm1returns Spark's result on every platform.This PR was prepared with AI assistance (Claude Code) and reviewed by me.