theirix commented on code in PR #19303:
URL: https://github.com/apache/datafusion/pull/19303#discussion_r2616363279


##########
datafusion/functions/src/math/power.rs:
##########
@@ -647,4 +671,239 @@ mod tests {
             "Not yet implemented: Negative scale is not yet supported value: 
-1"
         );
     }
+
+    #[test]
+    fn test_power_coerce_types() {
+        let power_func = PowerFunc::new();
+
+        // Int64 base with Int64 exponent -> both stay Int64
+        let result = power_func
+            .coerce_types(&[DataType::Int64, DataType::Int64])
+            .unwrap();
+        assert_eq!(result, vec![DataType::Int64, DataType::Int64]);
+
+        // Float64 base with Float64 exponent -> both stay Float64
+        let result = power_func
+            .coerce_types(&[DataType::Float64, DataType::Float64])
+            .unwrap();
+        assert_eq!(result, vec![DataType::Float64, DataType::Float64]);
+
+        // Int64 base with Float64 exponent -> base coerced to Float64
+        // This is needed because integer power doesn't support 
negative/fractional exponents
+        let result = power_func
+            .coerce_types(&[DataType::Int64, DataType::Float64])
+            .unwrap();
+        assert_eq!(result, vec![DataType::Float64, DataType::Float64]);
+
+        // Int32 base with Float32 exponent -> both coerced to Float64
+        let result = power_func
+            .coerce_types(&[DataType::Int32, DataType::Float32])
+            .unwrap();
+        assert_eq!(result, vec![DataType::Float64, DataType::Float64]);
+
+        // Null base with Float64 exponent -> base coerced to Float64
+        let result = power_func
+            .coerce_types(&[DataType::Null, DataType::Float64])
+            .unwrap();
+        assert_eq!(result, vec![DataType::Float64, DataType::Float64]);
+
+        // Null base with Int64 exponent -> base stays Int64
+        let result = power_func
+            .coerce_types(&[DataType::Null, DataType::Int64])
+            .unwrap();
+        assert_eq!(result, vec![DataType::Int64, DataType::Int64]);
+    }
+
+    /// Test for issue where pow(10, -2.0) was failing with overflow error
+    /// when integer base was used with negative float exponent
+    #[test]
+    fn test_power_int_base_negative_float_exp() {

Review Comment:
   I think the only remaining SLT test now is `pow(2, -2)`



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