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


##########
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:
   I feel we'll need to reconsider this integer log path now that it's reduced 
to needing all these requirements:
   
   - 0 scale
   - integer base
   - can unscale
   
   Just for a more accurate computation 🤔 
   
   cc @theirix 



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