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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]