lidavidm commented on code in PR #36015:
URL: https://github.com/apache/arrow/pull/36015#discussion_r1224763143


##########
go/arrow/datatype_nested.go:
##########
@@ -309,17 +309,28 @@ func (t *StructType) Fields() []Field {
 
 func (t *StructType) Field(i int) Field { return t.fields[i] }
 
+// FieldByName gets the field with the given name.
+//
+// If there are multiple fields with the given name, FieldByName
+// returns the first such field.
 func (t *StructType) FieldByName(name string) (Field, bool) {
        i, ok := t.index[name]
        if !ok {
                return Field{}, false
        }
-       return t.fields[i], true
+       return t.fields[i[0]], true
 }
 
+// FieldIdx gets the index of the field with the given name.
+//
+// If there are multiple fields with the given name, FieldIdx returns
+// the index of the first first such field.
 func (t *StructType) FieldIdx(name string) (int, bool) {
        i, ok := t.index[name]
-       return i, ok
+       if ok {
+               return i[0], true
+       }
+       return -1, false
 }

Review Comment:
   Added the same methods Schema has, though the inconsistency admittedly bugs 
me (why is FieldsByName ([]Field, bool) but FieldIndices is just []int, and 
then there's FieldIndices vs FieldIdx -.-)



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