-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-36014: [Go] Allow duplicate field names in structs #36015
GH-36014: [Go] Allow duplicate field names in structs #36015
Conversation
a0ae203
to
99c3a25
Compare
go/arrow/datatype_nested.go
Outdated
// 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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a new method that will return the []int by name lookup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 -.-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blame InfluxDB who created the original impl 😛 lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@lidavidm Actually, with this, can you remove the |
Oh! I'll fix that, one moment |
Looks like it passes. |
LGTM! |
Benchmark runs are scheduled for baseline = a4d241c and contender = b642707. b642707 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Rationale for this change
The package segfaulted before.
What changes are included in this PR?
Allow duplicate field names (in general methods will return the first field if there are duplicates)
Are these changes tested?
Yes
Are there any user-facing changes?
Yes