shifluxxc commented on PR #19584:
URL: https://github.com/apache/datafusion/pull/19584#issuecomment-3715893861
```
fn log_decimal32(value: i32, scale: i8, base: f64) -> Result<f64,
ArrowError> {
if !base.is_finite() || base.trunc() != base {
return Err(ArrowError::ComputeError(format!(
"Log cannot use non-integer base: {base}"
)));
}
if (base as u32) < 2 {
return Err(ArrowError::ComputeError(format!(
"Log base must be greater than 1: {base}"
)));
}
// Match f64::log behaviour
if value <= 0 {
return Ok(f64::NAN);
}
if scale < 0 {
let actual_value = (value as f64) * 10.0_f64.powi(-(scale as i32));
Ok(actual_value.log(base))
} else {
let unscaled_value = decimal32_to_i32(value, scale)?;
if unscaled_value <= 0 {
return Ok(f64::NAN);
}
let log_value: u32 = unscaled_value.ilog(base as i32);
Ok(log_value as f64)
}
}
``
log_decimal32 currently bypasses decimal32_to_i32 when the scale is
negative, instead using a manual floating-point calculation, and is not used
elsewhere except for log, so how should i test it ?`
--
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]