Repository navigation
Allow log/pow on negative scale decimals #19250
Description
Activity
- changed the title
[-]Allow log on negative scale decimals[/-][+]Allow log/pow on negative scale decimals[/+]on Dec 10, 2025 take
@Jefffrey please review .
- addedregressionSomething that used to work no longer doesSomething that used to work no longer does
on Dec 14, 2025 - added a commit that references this issue
on Dec 19, 2025 Still pending:
- power
- log for decimal32/64 after recent PR: feat: Support log for Decimal32 and Decimal64 #18999
Hey @Jefffrey i have opened another PR , please review . Also i am not sure if the calculation shown in example doc for power function at
datafusion/functions/src/math/power.rsis correct ?``text the example doc
/// b^e * 10^(-s * e) * 10^s = b^e / 10^(s * (e-1))
/// ```
/// Example of 2.5 ^ 4 = 39:
/// 2.5 is represented as 25 with scale 1
/// The unscaled result is 25^4 = 390625
/// Scale it back to 1: 390625 / 10^4 = 39- added a commit that references this issue
on Dec 22, 2025 Now that we have merged the following PRs, shall we close this one?
I think there are still some checks to fix from a cursory glance at the code:
datafusion/datafusion/functions/src/utils.rs
Lines 202 to 206 in f1e5c94
if scale < 0 { Err(ArrowError::ComputeError( "Negative scale is not supported".into(), )) } else if scale == 0 { datafusion/datafusion/functions/src/utils.rs
Lines 219 to 223 in f1e5c94
if scale < 0 { Err(ArrowError::ComputeError( "Negative scale is not supported".into(), )) } else if scale == 0 { datafusion/datafusion/functions/src/utils.rs
Lines 236 to 240 in f1e5c94
if scale < 0 { Err(ArrowError::ComputeError( "Negative scale is not supported".into(), )) } else if scale == 0 { Reacted by Andrew LambThanks @Jefffrey -- I was asking because this issue is (rightly) listed as needed for the 52.0.0 release, which we are gearing up for next week. @shifluxxc do you think you will have time to complete the rest of the work? Maybe even writing some .slt tests that show the current behavior / errors would be valuable
@alamb i will try to raise a PR today itself addressing these issues, Thank you .
I think there are still some checks to fix from a cursory glance at the code:
datafusion/datafusion/functions/src/utils.rs
Lines 202 to 206 in f1e5c94
if scale < 0 {
Err(ArrowError::ComputeError(
"Negative scale is not supported".into(),
))
} else if scale == 0 {datafusion/datafusion/functions/src/utils.rs
Lines 219 to 223 in f1e5c94
if scale < 0 {
Err(ArrowError::ComputeError(
"Negative scale is not supported".into(),
))
} else if scale == 0 {datafusion/datafusion/functions/src/utils.rs
Lines 236 to 240 in f1e5c94
if scale < 0 {
Err(ArrowError::ComputeError(
"Negative scale is not supported".into(),
))
} else if scale == 0 {Update: this is fine, callers guard against passing in negative scale so this is intended
Reacted by Andrew LambThank you for double checknig @Jefffrey and for your help getting this resolved @shifluxxc
Is your feature request related to a problem or challenge?
#17023 introduced handling of decimals for log natively; previously we'd cast the input to float before performing the log.
It introduced a condition against negative scale decimals, as the implementation couldn't yet handle them. This is technically a regression as previously we could handle them via casting to float before doing the log.
Describe the solution you'd like
Short term solution: for negative scale decimals, cast to float to perform log
Long term/proper solution: improve decimal log code to handle negative scales
Additional context
Same for pow: #18032