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

   ## Which issue does this PR close?
   
   Fixes a regression introduced in #18032 where `pow(10, -2.0)` fails with:
   ```
   Arrow error: Arithmetic overflow: Exponent -2 in integer computation is out 
of bounds.
   ```
   
   ## Rationale for this change
   
   After #18032 added decimal support to the `power()` function, the custom 
type coercion kept integer bases as `Int64` while float exponents became 
`Float64`. However, `invoke_with_args()` assumed `Int64` exponent for `Int64` 
base and used integer power computation, which doesn't support negative 
exponents.
   
   ## What changes are included in this PR?
   
   Modified `coerce_types()` in `datafusion/functions/src/math/power.rs` to 
coerce integer bases to `Float64` when the exponent is `Float64`, since 
floating-point arithmetic is required for negative/fractional exponents.
   
   This matches the original behavior before #18032 where mixed types would 
both be coerced to `Float64`.
   
   ## Are these changes tested?
   
   Yes, added comprehensive tests:
   - `test_power_coerce_types` - verifies type coercion behavior
   - `test_power_int_base_negative_float_exp` - tests the specific regression 
case
   - `test_power_edge_cases_f64` - tests edge cases for float power (zero 
exponent, one base, negative base, NaN)
   - `test_power_edge_cases_i64` - tests edge cases for integer power
   - `test_power_i64_negative_exp_fails` - verifies integer power with negative 
exponent fails
   - `test_power_zero_base_negative_exp` - tests infinity result
   
   ## Are there any user-facing changes?
   
   No breaking changes. This restores the expected behavior of `pow()` with 
integer base and float exponent.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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