andygrove commented on code in PR #334:
URL: https://github.com/apache/datafusion-spark/pull/334#discussion_r4629087571


##########
crates/sqllogictest/test_files/math/ln.slt:
##########
@@ -8,7 +8,94 @@
 # For more information, please see:
 #   https://github.com/apache/datafusion/issues/15914
 
+
 ## Original Query: SELECT ln(1);
 ## PySpark 3.5.5 Result: {'ln(1)': 0.0, 'typeof(ln(1))': 'double', 
'typeof(1)': 'int'}
-#query
-#SELECT ln(1::int);
+query R
+SELECT ln(1::int);
+----
+0
+
+# Result is always DOUBLE
+query T
+SELECT arrow_typeof(ln(1::int));
+----
+Float64
+
+query R
+SELECT ln(2::double);
+----
+0.6931471805599453
+
+query R
+SELECT ln(0.5::double);
+----
+-0.6931471805599453
+
+# Integer, float and decimal inputs are cast to DOUBLE
+query RRRR
+SELECT ln(10::tinyint) AS a, ln(10::bigint) AS b, ln(10::float) AS c, 
ln(10::decimal(5, 2)) AS d;
+----
+2.302585092994046 2.302585092994046 2.302585092994046 2.302585092994046
+
+# Spark returns NULL, not -Infinity or NaN, for an input <= 0
+query RRRR
+SELECT ln(0::int) AS a, ln('-0.0'::double) AS b, ln(-1::int) AS c, 
ln('-Infinity'::double) AS d;
+----
+NULL NULL NULL NULL
+
+query R
+SELECT ln(NULL::double);
+----
+NULL
+
+# NaN is not <= 0, so NaN returns NaN
+query R
+SELECT ln('NaN'::double);
+----
+NaN
+
+query RRR
+SELECT ln('Infinity'::double), ln(1.7976931348623157e308::double), 
ln(4.9e-324::double);
+----
+Infinity 709.782712893384 -744.4400719213812
+
+# Array path, including NULL and non-positive rows
+query R
+SELECT ln(a) FROM (VALUES (1::double), (0::double), (NULL::double), 
(-5::double), (2::double)) AS t(a);
+----
+0
+NULL
+NULL
+NULL
+0.6931471805599453
+
+# Spark uses StrictMath.log (fdlibm), which differs from Rust's f64::ln in the
+# last digit for some inputs (f64::ln gives -0.4000133310645469 here)
+query R
+SELECT ln(0.670311110015402::double);
+----
+-0.40001333106454684
+
+# Spark implicitly casts a string argument to DOUBLE
+query RR
+SELECT ln('10'), ln(a) FROM (VALUES ('1'), (NULL)) AS t(a);
+----
+2.302585092994046 0
+2.302585092994046 NULL
+
+statement ok
+set datafusion.execution.enable_ansi_mode = true;
+
+query error Cannot cast string 'abc' to value of Float64 type
+SELECT ln('abc');
+
+statement ok
+set datafusion.execution.enable_ansi_mode = false;
+
+# Spark 4.2.0 returns NULL for a malformed string when ANSI mode is off; 
DataFusion errors
+# https://github.com/apache/datafusion-spark/issues/88
+# query R
+# SELECT ln('abc');
+# ----
+# NULL

Review Comment:
   Thanks. e520f45 names both string differences in the module doc in `log.rs`. 
Since #368 landed I've recorded them as live records with `# xfail spark:` 
markers linking #88, rather than commented-out queries. `ln('abc')` with ANSI 
mode off and `ln('10d')` both assert DataFusion's current cast error, so the 
PySpark runner tracks them and will flag them once #88 fixes the cast. I also 
rebased onto `main` now that #333 has merged.



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