martin-g commented on code in PR #19315:
URL: https://github.com/apache/datafusion/pull/19315#discussion_r2624840743


##########
datafusion/functions/src/math/log.rs:
##########
@@ -116,13 +116,18 @@ fn log_decimal128(value: i128, scale: i8, base: f64) -> 
Result<f64, ArrowError>
         )));
     }
 
-    let unscaled_value = decimal128_to_i128(value, scale)?;
-    if unscaled_value > 0 {
+    if value <= 0 {
+        // Reflect f64::log behaviour
+        return Ok(f64::NAN);
+    }
+
+    if scale < 0 {
+        let actual_value = (value as f64) * 10.0_f64.powi(-scale as i32);

Review Comment:
   ```suggestion
           let actual_value = (value as f64) * 10.0_f64.powi(-(scale as i32));
   ```
   The casting should be before the negation. 
   I doubt anyone would use scale=-128 but this is more correct.



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