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


##########
datafusion/functions/src/math/log.rs:
##########
@@ -109,80 +109,59 @@ fn is_valid_integer_base(base: f64) -> bool {
 }
 
 /// Calculate logarithm for Decimal32 values.
-/// For integer bases >= 2 with non-negative scale, uses the efficient u32 
ilog algorithm.
-/// Otherwise falls back to f64 computation.
+/// For integer bases >= 2 with zero scale, return an exact integer log when 
the
+/// value is a perfect power of the base. Otherwise falls back to f64 
computation.
 fn log_decimal32(value: i32, scale: i8, base: f64) -> Result<f64, ArrowError> {
-    if is_valid_integer_base(base)
-        && scale >= 0
-        && let Some(unscaled) = unscale_to_u32(value, scale)
+    if scale == 0
+        && is_valid_integer_base(base)
+        && let Ok(unscaled) = u32::try_from(value)
+        && unscaled > 0

Review Comment:
   That's true. I would start with more test cases to express our expectations 
on int/float semantics, like stated in the PR description.
   
   For unscaling, I believe it could be improved in general, there are some 
edge cases. One attempt is here https://github.com/apache/datafusion/pull/19874



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