-
Notifications
You must be signed in to change notification settings - Fork 4.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
[Go] Ensure iterated and emitted types are registered. #23890
Conversation
Codecov Report
@@ Coverage Diff @@
## master #23890 +/- ##
==========================================
- Coverage 73.84% 73.30% -0.55%
==========================================
Files 707 720 +13
Lines 95746 96059 +313
==========================================
- Hits 70708 70414 -294
- Misses 23721 24329 +608
+ Partials 1317 1316 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Assigning reviewers. If you would like to opt out of this review, comment R: @riteshghorse for label go. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
@@ -113,7 +123,9 @@ func Iter1[T any]() { | |||
registerFunc := func(s exec.ReStream) exec.ReusableInput { | |||
return &iter1[T]{s: s} | |||
} | |||
exec.RegisterInput(reflect.TypeOf(i).Elem(), registerFunc) | |||
itT := reflect.TypeOf(i).Elem() |
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.
Hey @lostluck
I just started a test run with your changes applied with the bigtable io connector (#23411).
Unfortunately I still ran into the following error: reflect.Set: value of type struct { RowKey string; Ops []struct { Family string; Column string; Ts int64; Value []uint8 }; GroupKey string } is not assignable to type bigtableio.Mutation
.
I played around with this implementation but wasn't able to make it work. My knowledge on the reflect package is somehow limited though.
That's very strange. That's what the additional registrations in this PR
should be handling.
That error means it didn't have the type registered and had to
synthetically generate it. In simple cases this satisfies Go's
Assignability rules but not so kuch for nested structs.
Is there more of a panic trace where that error comes from?
…On Sat, Oct 29, 2022, 8:06 AM capthiron ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In sdks/go/pkg/beam/register/iter.go
<#23890 (comment)>:
> @@ -113,7 +123,9 @@ func Iter1[T any]() {
registerFunc := func(s exec.ReStream) exec.ReusableInput {
return &iter1[T]{s: s}
}
- exec.RegisterInput(reflect.TypeOf(i).Elem(), registerFunc)
+ itT := reflect.TypeOf(i).Elem()
Hey @lostluck <https://github.com/lostluck>
I just started a test run with your changes applied with the bigtable io
connector (#23411 <#23411>).
Unfortunately I still ran into the following error: reflect.Set: value of
type struct { RowKey string; Ops []struct { Family string; Column string;
Ts int64; Value []uint8 }; GroupKey string } is not assignable to type
bigtableio.Mutation.
I played around with this implementation but wasn't able to make it work.
My knowledge on the reflect package is somehow limited though.
—
Reply to this email directly, view it on GitHub
<#23890 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADKDOFPTGUI2RX7BWCNGSODWFU4QLANCNFSM6AAAAAARROGTG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Ah, I'm neglecting to strip the pointer from the type. Turns out "derived"
types like pointers and slices "don't exist" with how this registry was
built. Easy enough to fix (and test). Thanks for catching it!
…On Sat, Oct 29, 2022, 8:41 AM Robert Burke ***@***.***> wrote:
That's very strange. That's what the additional registrations in this PR
should be handling.
That error means it didn't have the type registered and had to
synthetically generate it. In simple cases this satisfies Go's
Assignability rules but not so kuch for nested structs.
Is there more of a panic trace where that error comes from?
On Sat, Oct 29, 2022, 8:06 AM capthiron ***@***.***> wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In sdks/go/pkg/beam/register/iter.go
> <#23890 (comment)>:
>
> > @@ -113,7 +123,9 @@ func Iter1[T any]() {
> registerFunc := func(s exec.ReStream) exec.ReusableInput {
> return &iter1[T]{s: s}
> }
> - exec.RegisterInput(reflect.TypeOf(i).Elem(), registerFunc)
> + itT := reflect.TypeOf(i).Elem()
>
> Hey @lostluck <https://github.com/lostluck>
> I just started a test run with your changes applied with the bigtable io
> connector (#23411 <#23411>).
> Unfortunately I still ran into the following error: reflect.Set: value
> of type struct { RowKey string; Ops []struct { Family string; Column
> string; Ts int64; Value []uint8 }; GroupKey string } is not assignable to
> type bigtableio.Mutation.
> I played around with this implementation but wasn't able to make it work.
> My knowledge on the reflect package is somehow limited though.
>
> —
> Reply to this email directly, view it on GitHub
> <#23890 (review)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ADKDOFPTGUI2RX7BWCNGSODWFU4QLANCNFSM6AAAAAARROGTG4>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
RFAL |
- bugfix apache#23890 will ensure that register.Iter1 will implicitly register bigtableio.Mutation
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.
The changes looks good to me, thanks!
Run Go PostCommit |
Fixes #23889
Resolves an issue with a pattern for transform package authors where they receive a given type from users, where that received type wouldn't be registered, leading to potential issues at authoring and testing time.
Transforms registered with
register
won't have types in their emitters or iterators registered due to complexities WRT generics. Instead, also ensure those types are registered with the Iter and Emitter* methods.Also moves the iterator and emitter tests to co-aligned files, to make them easier to find.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username
).addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.