zeroshade commented on a change in pull request #11359:
URL: https://github.com/apache/arrow/pull/11359#discussion_r744292268



##########
File path: go/arrow/array/interval.go
##########
@@ -86,6 +88,29 @@ func (a *MonthInterval) setData(data *Data) {
        }
 }
 
+func (a *MonthInterval) getOneForMarshal(i int) interface{} {
+       if a.IsValid(i) {
+               return a.values[i]
+       }
+       return nil
+}
+
+func (a *MonthInterval) MarshalJSON() ([]byte, error) {
+       if a.NullN() == 0 {
+               return json.Marshal(a.values)
+       }
+       vals := make([]interface{}, a.Len())
+       for i := 0; i < a.Len(); i++ {
+               if a.IsValid(i) {
+                       vals[i] = a.values[i]

Review comment:
       It was handled by the change in the `datatype_fixedwidth.go` file by 
adding `MarshalJSON` and `UnmarshalJSON` functions to the `MonthInterval` type 
here: 
https://github.com/apache/arrow/pull/11359/files#diff-ada6f476fe71c04e54cb986f027d91bad2517d3a5a1f278115a80ea3bcc18482R333
 When it goes to marshal the array of `MonthInterval` values, it'll use the 
`MarshalJSON` and `UnmarshalJSON` functions defined on the type, rather than 
defaulting to just treating it like an integer.




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