zeroshade commented on code in PR #1515:
URL: https://github.com/apache/arrow-go/pull/1515#discussion_r4542823155


##########
arrow/array/decimal.go:
##########
@@ -96,8 +96,11 @@ func (a *baseDecimal[T]) GetOneForMarshal(i int) any {
        }
 
        typ := a.DataType().(arrow.DecimalType)
-       n, scale := a.Value(i), typ.GetScale()
-       return utils.FormatDecimalG(n, typ.GetPrecision(), scale)
+       s, err := utils.FormatDecimalG(a.Value(i), typ)
+       if err != nil {
+               return fmt.Sprintf("<scale out of range, cannot format 
Decimal%d value>", typ.BitWidth())

Review Comment:
   nit: this is fine for `String`/`ValueStr`, but `json.Marshal` on such an 
array succeeds and writes the placeholder as if it were data: `["\u003cscale 
out of range, cannot format Decimal128 value\u003e"]`. 
`baseDecimal.MarshalJSON` could check the type's scale once and return the 
error instead. Decimals nested in lists or structs would still get the 
placeholder through `GetOneForMarshal`, so leaving this for the follow-up that 
rejects these types at creation is fine too.



-- 
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]

Reply via email to