You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "neilconway (via GitHub)" <gi...@apache.org> on 2026/09/01 19:04:10 UTC
[I] Casting decimal -> decimal with large scale is buggy [arrow-rs]
neilconway opened a new issue, #10946:
URL: https://github.com/apache/arrow-rs/issues/10946
### Describe the bug
Casting decimal -> decimal with a much larger scale can produce incorrect values, including panics in debug mode.
### To Reproduce
```rust
use arrow_array::{Array, Decimal256Array};
use arrow_buffer::i256;
use arrow_cast::{cast_with_options, CastOptions};
use arrow_schema::DataType;
let array = Decimal256Array::from(vec![
i256::from_i128(1),
i256::from_i128(10_i128.pow(16)),
i256::from_i128(10_i128.pow(17)),
])
.with_precision_and_scale(76, 0)
.unwrap();
// Strict mode; safe mode returns the same values (no nulls, no error)
let options = CastOptions { safe: false, ..Default::default() };
let result = cast_with_options(&array, &DataType::Decimal256(76, 60), &options).unwrap();
```
Results:
```
1 -> 1000000000000000000000000000000000000000000000000000000000000
10000000000000000 -> 10000000000000000000000000000000000000000000000000000000000000000000000000000
100000000000000000 -> -15792089237316195423570985008687907853269984665640564039457584007913129639936
```
The first result is correct.
The second result exceeds the maximum value representable at precision 76 but is returned without error.
The third result is just wrong.
### Expected behavior
_No response_
### Additional context
_No response_
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Casting decimal -> decimal with large scale is buggy [arrow-rs]
Posted by "neilconway (via GitHub)" <gi...@apache.org>.
neilconway commented on issue #10946:
URL: https://github.com/apache/arrow-rs/issues/10946#issuecomment-5498966357
take
--
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