You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "fxeqxmulfx (via GitHub)" <gi...@apache.org> on 2025/10/04 20:43:19 UTC
[I] Decimal precision out of range [arrow]
fxeqxmulfx opened a new issue, #47698:
URL: https://github.com/apache/arrow/issues/47698
### Describe the bug, including details regarding any error messages, version, and platform.
```python
import pyarrow as pa
import pyarrow.compute as pc
x = pa.array((1, 2, 3, 4, 5), type=pa.decimal128(38, 19))
print(
pc.subtract_checked(x, x)
) # ArrowInvalid: Decimal precision out of range [1, 38]: 39
```
### Component(s)
Python
--
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: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] pc.subtract_checked(x, x) with x as pa.array((1, 2, 3, 4, 5), type=pa.decimal128(38, 19)) raises "Decimal precision out of range" [arrow]
Posted by "thisisnic (via GitHub)" <gi...@apache.org>.
thisisnic closed issue #47698: pc.subtract_checked(x, x) with x as pa.array((1, 2, 3, 4, 5), type=pa.decimal128(38, 19)) raises "Decimal precision out of range"
URL: https://github.com/apache/arrow/issues/47698
--
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: issues-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] pc.subtract_checked(x, x) with x as pa.array((1, 2, 3, 4, 5), type=pa.decimal128(38, 19)) raises "Decimal precision out of range" [arrow]
Posted by "zanmato1984 (via GitHub)" <gi...@apache.org>.
zanmato1984 commented on issue #47698:
URL: https://github.com/apache/arrow/issues/47698#issuecomment-3686233765
Hi @fxeqxmulfx , I think this is an expected behavior. When doing decimal addition/subtraction, we promote the result precision to `max(p1 - s1, p2 - s2) + s1 + 1` (for your case, `39`) to prevent overflow, which exceeds the max precision of `decimal128` `38`. Further implicit promoting the result type to `decimal256` wouldn't be desired as well because this may cause more surprises and overhead than benefits.
If this causes any trouble for your real use case, you can probably use, or explicit cast it to, `decimal256`.
Thanks.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org