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/08/26 16:54:19 UTC
[I] Decimal zero with negative scale is formatted as "000" [arrow-rs]
neilconway opened a new issue, #10865:
URL: https://github.com/apache/arrow-rs/issues/10865
### Describe the bug
Formatting a decimal with negative scale pads the digit string with `|scale|` zeros; for a value of zero this yields an output like "000". Aside from being odd, this is also an illegal JSON number (the JSON spec forbids leading zeroes).
### To Reproduce
```rust
use arrow_array::{ArrayRef, Decimal128Array, RecordBatch};
use std::sync::Arc;
let a = Decimal128Array::from(vec![0, 12])
.with_precision_and_scale(10, -2)
.unwrap();
a.value_as_string(0); // "000" — expected "0"
a.value_as_string(1); // "1200", correct
let batch = RecordBatch::try_from_iter([("c", Arc::new(a) as ArrayRef)]).unwrap();
let mut buf = Vec::new();
let mut w = arrow_json::LineDelimitedWriter::new(&mut buf);
w.write_batches(&[&batch]).unwrap();
w.finish().unwrap();
String::from_utf8(buf).unwrap();
// {"c":000} <- invalid JSON number
// {"c":1200}
```
### 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] Decimal zero with negative scale is formatted as "000" [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey closed issue #10865: Decimal zero with negative scale is formatted as "000"
URL: https://github.com/apache/arrow-rs/issues/10865
--
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
Re: [I] Decimal zero with negative scale is formatted as "000" [arrow-rs]
Posted by "neilconway (via GitHub)" <gi...@apache.org>.
neilconway commented on issue #10865:
URL: https://github.com/apache/arrow-rs/issues/10865#issuecomment-5428324518
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