zeroshade opened a new pull request, #849:
URL: https://github.com/apache/arrow-go/pull/849
### Rationale for this change
Decimal arrays stringify the raw `decimal.Num` struct instead of the scaled
logical value. `fmt.Println` on a decimal array — or on a
`Record`/`RecordBatch` containing one — prints e.g. `{1999 0}` instead of
`19.99`, even though `ValueStr` already formats the value correctly using the
type's scale. This is inconsistent with `ValueStr`/JSON output and with other
Arrow implementations (e.g. PyArrow prints `19.99`).
### What changes are included in this PR?
- `baseDecimal[T].String()` now formats each non-null value via `ValueStr`
(which applies the type's scale through `GetOneForMarshal`) instead of
`fmt.Sprintf("%v", Value(i))`. Because `baseDecimal` is generic, this corrects
`Decimal32/64/128/256` at once, and `RecordBatch` printing inherits the fix
through the column `String()` path (`record.go`).
- Updated two existing slice-test assertions in `decimal128_test.go` /
`decimal256_test.go` that pinned the old raw-struct output (they were already
inconsistent with the adjacent `ValueStr` expectations on the next lines).
- Added `TestDecimal128StringScaled`, reproducing the issue (`decimal128(5,
2)` = `19.99`) and asserting both the array `String()` and the `RecordBatch`
output.
### Are these changes tested?
Yes. `go test ./arrow/array/` passes, including the new regression test and
the updated slice tests. `go build ./...` and `go vet`/golangci-lint (via
pre-commit) pass.
### Are there any user-facing changes?
Yes — the textual output of `String()` on decimal arrays, and of any
`Record`/`RecordBatch` containing decimal columns, now shows scaled decimal
values (e.g. `19.99`) instead of the internal struct (e.g. `{1999 0}`). This
only affects human-readable stringification; binary/IPC/JSON representations
are unchanged.
Closes #848
--
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]