kosiew commented on code in PR #26382:
URL: https://github.com/apache/datafusion/pull/26382#discussion_r4492098902


##########
datafusion/sqllogictest/test_files/spark/math/pow.slt:
##########
@@ -142,19 +153,46 @@ SELECT pow(0.5, CAST('-Infinity' AS DOUBLE));
 ----
 Infinity
 
+## A base of 1 or -1 with an infinite exponent gives NaN in Spark
+query R
+SELECT pow(1.0, CAST('Infinity' AS DOUBLE));
+----
+NaN
+
+query R
+SELECT pow(-1.0, CAST('Infinity' AS DOUBLE));
+----
+NaN
+
+query R
+SELECT pow(1.0, CAST('-Infinity' AS DOUBLE));
+----
+NaN
+
+query R
+SELECT pow(-1.0, CAST('-Infinity' AS DOUBLE));
+----
+NaN
+
 # Test Array x Array
 statement ok
 CREATE TABLE t1(a DOUBLE, b DOUBLE) AS VALUES
 (0.0, -1.0),
 (2.0, 3.0),
-(CAST(NULL AS DOUBLE), 1.0);
+(CAST(NULL AS DOUBLE), 1.0),
+(CAST('-0.0' AS DOUBLE), -3.0),
+(1.0, CAST('NaN' AS DOUBLE)),
+(-1.0, CAST('Infinity' AS DOUBLE));
 
 query R
 SELECT pow(a, b) FROM t1;

Review Comment:
   Optional coverage: could we add `SELECT pow(1.0, b), pow(a, CAST('Infinity' 
AS DOUBLE)) FROM t1` before dropping the table? This would exercise 
broadcasting in both argument positions and NULL-base propagation, though not 
NULL-exponent propagation since `t1.b` contains no NULL. Both directions 
already use the shared helper, so this is not a merge requirement.



##########
datafusion/spark/src/function/math/pow.rs:
##########
@@ -34,10 +35,12 @@ use datafusion_functions::math::power::PowerFunc;
 
 /// Spark-compatible implementation of `pow` / `power`.
 ///
-/// Behavioural difference from the DataFusion default:
+/// Behavioural differences from the DataFusion default:
 /// - `pow(0, <negative>)` → `Infinity`  (IEEE 754 / Spark semantics)
 ///   The default raises `"zero raised to a negative power is undefined"` to
 ///   match PostgreSQL.
+/// - A `NaN` exponent, or a base of `1` or `-1` with an infinite exponent,

Review Comment:
   Could we clarify the documentation to identify `pow(1, NaN)` as the 
difference from default DataFusion, since `pow(2, NaN)` already returns NaN? 
The zero-base description should also distinguish positive zero yielding 
+Infinity from negative zero raised to a negative odd integer yielding 
-Infinity.



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