zeroshade commented on code in PR #14278:
URL: https://github.com/apache/arrow/pull/14278#discussion_r984059003
##########
go/arrow/csv/writer.go:
##########
@@ -219,6 +219,38 @@ func (w *Writer) Write(record arrow.Record) error {
recs[i][j] = w.nullValue
}
}
+ case *arrow.Decimal128Type:
+ fieldType :=
w.schema.Field(j).Type.(*arrow.Decimal128Type)
+ scale := fieldType.Scale
+ arr := col.(*array.Decimal128)
+ for i := 0; i < arr.Len(); i++ {
+ if arr.IsValid(i) {
+ decString :=
arr.Value(i).BigInt().Text(10)
+ decimalLocation := len(decString) -
int(scale)
+ if decimalLocation >= 0 && scale > 0 {
+ decString =
decString[:decimalLocation] + "." + decString[decimalLocation:]
+ }
+ recs[i][j] = decString
Review Comment:
No prob! At this rate I should probably just incorporate this to the
`decimal128.Num` and `decimal256.Num` types with a `ToString(precision, scale
int32) string` method, but that can be a separate change. :smile:
--
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]