neilconway opened a new pull request, #22651:
URL: https://github.com/apache/datafusion/pull/22651

   ## Which issue does this PR close?
   
   - Closes #22480
   - Closes #22510
   
   ## Rationale for this change
   
   `power(decimal, int)` attempts to compute `power` without loss of precision. 
For negative exponents, the code did the computation in `Float64` and then cast 
the result back to `decimal`. Unfortunately, the previous implementation got 
this wrong: using the precision of the base might not be sufficient to 
accurately represent the result. It seems simpler to return `Float64` for the 
negative exponent case.
   
   We could potentially try to return `decimal` for non-negative exponents and 
`Float64` for negative exponents, but that is complicated, and also means that 
the code would produce different results for literal arguments vs. columnar 
arguments, which I think should be avoided.
   
   On reflection, it seems simplest to just remove the `power(decimal, int)` 
code path entirely, and have `power` always return `Float64`. This also fixes 
another issue in the decimal code path (#22480)
   
   ## What changes are included in this PR?
   
   * Remove `power(decimal, ...)` support; both args will be coerced to Float64 
if necessary, and the function will always return Float64
   * Update SLT
   * Add new test cases for #22480 and #22510
   
   ## Are these changes tested?
   
   Yes.
   
   ## Are there any user-facing changes?
   
   Yes, `power(decimal, ...)` will now return `Float64`.
   


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