Skip to content
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

Merged
merged 4 commits into from
Jun 12, 2023

Conversation

lidavidm
Copy link
Member

@lidavidm lidavidm commented Jun 9, 2023

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

@lidavidm lidavidm force-pushed the gh-36014-duplicate-field-names branch from a0ae203 to 99c3a25 Compare June 9, 2023 18:45
Comment on lines 324 to 334
// 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
}
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Jun 9, 2023
@github-actions github-actions bot added awaiting change review Awaiting change review awaiting changes Awaiting changes and removed awaiting changes Awaiting changes awaiting change review Awaiting change review labels Jun 9, 2023
@github-actions github-actions bot added awaiting change review Awaiting change review awaiting changes Awaiting changes and removed awaiting changes Awaiting changes awaiting change review Awaiting change review labels Jun 12, 2023
Copy link
Member

@zeroshade zeroshade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting changes Awaiting changes labels Jun 12, 2023
@zeroshade
Copy link
Member

zeroshade commented Jun 12, 2023

@lidavidm Actually, with this, can you remove the skip_category('Go') from archery/datagen.py for the generate_duplicate_fieldnames_case()? Or do you want to enable the integration test as a separate PR? That's the only remaining integration test that skips Go 😄

@lidavidm
Copy link
Member Author

Oh! I'll fix that, one moment

@lidavidm
Copy link
Member Author

Looks like it passes.

@zeroshade
Copy link
Member

LGTM!

@lidavidm lidavidm merged commit b642707 into apache:main Jun 12, 2023
21 checks passed
@ursabot
Copy link

ursabot commented Jun 12, 2023

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.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️1.27% ⬆️0.0%] test-mac-arm
[Finished ⬇️0.0% ⬆️0.65%] ursa-i9-9960x
[Finished ⬇️0.89% ⬆️0.18%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] b642707f ec2-t3-xlarge-us-east-2
[Finished] b642707f test-mac-arm
[Finished] b642707f ursa-i9-9960x
[Finished] b642707f ursa-thinkcentre-m75q
[Finished] a4d241c2 ec2-t3-xlarge-us-east-2
[Finished] a4d241c2 test-mac-arm
[Finished] a4d241c2 ursa-i9-9960x
[Finished] a4d241c2 ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Go] Handle duplicate field names in structs
3 participants