andygrove commented on code in PR #334: URL: https://github.com/apache/datafusion-spark/pull/334#discussion_r4603025422
########## crates/sqllogictest/test_files/math/log1p.slt: ########## @@ -8,7 +8,58 @@ # For more information, please see: # https://github.com/apache/datafusion/issues/15914 + ## Original Query: SELECT log1p(0); ## PySpark 3.5.5 Result: {'LOG1P(0)': 0.0, 'typeof(LOG1P(0))': 'double', 'typeof(0)': 'int'} -#query -#SELECT log1p(0::int); +query R +SELECT log1p(0::int); +---- +0 + +query T +SELECT arrow_typeof(log1p(0::int)); +---- +Float64 + +query RR +SELECT log1p(1::int), log1p(-0.5::double); +---- +0.6931471805599453 -0.6931471805599453 + +# Accurate near 0, where ln(1 + x) would round to 0 +query R +SELECT log1p(1e-20::double); +---- +0.00000000000000000001 + +# Spark returns NULL, not -Infinity or NaN, for an input <= -1 +query RRR +SELECT log1p(-1::int), log1p(-2::int), log1p('-Infinity'::double); +---- +NULL NULL NULL + +query RRR +SELECT log1p(NULL::double), log1p('NaN'::double), log1p('Infinity'::double); +---- +NULL NaN Infinity + +query R +SELECT log1p(a) FROM (VALUES (0::double), (-1::double), (NULL::double), (-0.5::double)) AS t(a); +---- +0 +NULL +NULL +-0.6931471805599453 + +# Spark uses StrictMath.log1p (fdlibm), which differs from Rust's f64::ln_1p in +# the last digit for some inputs (f64::ln_1p gives 0.5130099025005953 here) +query R +SELECT log1p(0.670311110015402::double); +---- +0.5130099025005954 + +# -0.0 is above the asymptote, and log1p(-0.0) is -0.0 +query R +SELECT log1p(-0.0::double); Review Comment: Fixed in 3cbe805, along with the same literal in `ln.slt`. -- 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]
