joellubi commented on code in PR #43958:
URL: https://github.com/apache/arrow/pull/43958#discussion_r1750879986


##########
go/arrow/internal/arrjson/arrjson.go:
##########
@@ -2038,6 +2079,47 @@ func f64ToJSON(arr *array.Float64) []interface{} {
        return o
 }
 
+func decimal32ToJSON(arr *array.Decimal32) []interface{} {
+       o := make([]interface{}, arr.Len())
+       for i := range o {
+               o[i] = arr.ValueStr(i)
+       }
+       return o
+}
+
+func decimal32FromJSON(vs []interface{}) []decimal.Decimal32 {
+       var tmp big.Int
+       o := make([]decimal.Decimal32, len(vs))
+       for i, v := range vs {
+               if err := tmp.UnmarshalJSON([]byte(v.(string))); err != nil {
+                       panic(fmt.Errorf("could not convert %v (%T) to 
decimal128: %w", v, v, err))

Review Comment:
   ```suggestion
                        panic(fmt.Errorf("could not convert %v (%T) to 
decimal32: %w", v, v, err))
   ```



##########
go/arrow/internal/arrjson/arrjson.go:
##########
@@ -2038,6 +2079,47 @@ func f64ToJSON(arr *array.Float64) []interface{} {
        return o
 }
 
+func decimal32ToJSON(arr *array.Decimal32) []interface{} {
+       o := make([]interface{}, arr.Len())
+       for i := range o {
+               o[i] = arr.ValueStr(i)
+       }
+       return o
+}
+
+func decimal32FromJSON(vs []interface{}) []decimal.Decimal32 {
+       var tmp big.Int
+       o := make([]decimal.Decimal32, len(vs))
+       for i, v := range vs {
+               if err := tmp.UnmarshalJSON([]byte(v.(string))); err != nil {
+                       panic(fmt.Errorf("could not convert %v (%T) to 
decimal128: %w", v, v, err))
+               }
+
+               o[i] = decimal.Decimal32(tmp.Int64())
+       }
+       return o
+}
+
+func decimal64ToJSON(arr *array.Decimal64) []interface{} {
+       o := make([]interface{}, arr.Len())
+       for i := range o {
+               o[i] = arr.ValueStr(i)
+       }
+       return o
+}
+
+func decimal64FromJSON(vs []interface{}) []decimal.Decimal64 {
+       var tmp big.Int
+       o := make([]decimal.Decimal64, len(vs))
+       for i, v := range vs {
+               if err := tmp.UnmarshalJSON([]byte(v.(string))); err != nil {
+                       panic(fmt.Errorf("could not convert %v (%T) to 
decimal128: %w", v, v, err))

Review Comment:
   ```suggestion
                        panic(fmt.Errorf("could not convert %v (%T) to 
decimal64: %w", v, v, err))
   ```



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