Repository navigation
Commit 7ed9a0b
authored
fix: Remove
## Which issue does this PR close?
- Closes apache#22480
- Closes apache#22510
## Rationale for this change
`power(decimal, int)` attempted 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, because `decimal` might not have
enough precision to accurately represent the result. It seems simpler to
return `Float64` for the negative exponent case.
We could potentially try to return `decimal` only 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 (apache#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 apache#22480 and apache#22510
## Are these changes tested?
Yes.
## Are there any user-facing changes?
Yes, `power(decimal, ...)` will now return `Float64`.power(decimal, int) code path (apache#22651)1 parent d54ce65 commit 7ed9a0b
5 files changed
Lines changed: 89 additions & 430 deletions
File tree
- datafusion
- core
- src/execution
- tests/expr_api
- functions/src/math
- sqllogictest/test_files
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
642 | | - | |
| 642 | + | |
643 | 643 | | |
644 | 644 | | |
645 | | - | |
| 645 | + | |
646 | 646 | | |
647 | 647 | | |
648 | | - | |
| 648 | + | |
| 649 | + | |
649 | 650 | | |
650 | 651 | | |
651 | | - | |
| 652 | + | |
652 | 653 | | |
653 | 654 | | |
654 | | - | |
655 | | - | |
656 | | - | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
657 | 658 | | |
658 | 659 | | |
659 | 660 | | |
660 | 661 | | |
661 | 662 | | |
662 | 663 | | |
663 | | - | |
| 664 | + | |
664 | 665 | | |
665 | 666 | | |
666 | 667 | | |
| |||
0 commit comments