Skip to content

Allow log/pow on negative scale decimals #19250

Description

@Jefffrey

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

Activity

  1. added theissue type on Dec 10, 2025
  2. changed the title [-]Allow log on negative scale decimals[/-] [+]Allow log/pow on negative scale decimals[/+] on Dec 10, 2025
  3. shifluxxc commented on Dec 13, 2025

    @shifluxxc
    Contributor

    take

  4. shifluxxc commented on Dec 14, 2025

    @shifluxxc
    Contributor

    @Jefffrey please review .

  5. added
    regressionSomething that used to work no longer does
    on Dec 14, 2025
  6. Jefffrey commented on Dec 19, 2025

    @Jefffrey
    ContributorAuthor

    Still pending:

  7. shifluxxc commented on Dec 19, 2025

    @shifluxxc
    Contributor

    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.rs is 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

  8. alamb commented on Dec 31, 2025

    @alamb
    Contributor
  9. Jefffrey commented on Dec 31, 2025

    @Jefffrey
    ContributorAuthor

    I think there are still some checks to fix from a cursory glance at the code:

    if scale < 0 {
    Err(ArrowError::ComputeError(
    "Negative scale is not supported".into(),
    ))
    } else if scale == 0 {

    if scale < 0 {
    Err(ArrowError::ComputeError(
    "Negative scale is not supported".into(),
    ))
    } else if scale == 0 {

    if scale < 0 {
    Err(ArrowError::ComputeError(
    "Negative scale is not supported".into(),
    ))
    } else if scale == 0 {

  10. alamb commented on Dec 31, 2025

    @alamb
    Contributor

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

  11. shifluxxc commented on Dec 31, 2025

    @shifluxxc
    Contributor

    @alamb i will try to raise a PR today itself addressing these issues, Thank you .

  12. Jefffrey commented on Jan 6, 2026

    @Jefffrey
    ContributorAuthor

    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

  13. alamb commented on Jan 7, 2026

    @alamb
    Contributor

    Thank you for double checknig @Jefffrey and for your help getting this resolved @shifluxxc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestregressionSomething that used to work no longer does

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions