zeroshade commented on a change in pull request #11359:
URL: https://github.com/apache/arrow/pull/11359#discussion_r741439840
##########
File path: go/arrow/array/struct.go
##########
@@ -105,6 +107,36 @@ func (a *Struct) setData(data *Data) {
}
}
+func (a *Struct) getOneForMarshal(i int) interface{} {
+ if a.IsNull(i) {
+ return nil
+ }
+
+ tmp := make(map[string]interface{})
+ fieldList := a.data.dtype.(*arrow.StructType).Fields()
+ for j, d := range a.fields {
+ tmp[fieldList[j].Name] = d.getOneForMarshal(i)
+ }
+ return tmp
+}
+
+func (a *Struct) MarshalJSON() ([]byte, error) {
+ var buf bytes.Buffer
+ enc := json.NewEncoder(&buf)
+
+ buf.WriteByte('[')
+ for i := 0; i < a.Len(); i++ {
Review comment:
In a struct column, each "value" in the list, is an object consisting of
keys from the struct field names with values for the corresponding index.
For example, a `struct<a: int, b: float>` column would be marshalled to `[
{"a": <a[0]>, "b": <b[0]>}, {"a": <a[1]>, "b": <b[1]> }, .... ]`. Does that
make more sense?
--
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]