You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "yyy1000 (via GitHub)" <gi...@apache.org> on 2023/01/27 14:43:39 UTC
[GitHub] [beam] yyy1000 opened a new pull request, #25203: Fix interface{} in iter& emit type of DoFn in Go
yyy1000 opened a new pull request, #25203:
URL: https://github.com/apache/beam/pull/25203
Fix #23278
I added type checks in the core/funcx package, and now the interface{} type in iter and emit function will not work.
I tested it with function 'New' in core/funcx/fn.go and found it could work well, but I'm not pretty sure that it finished all the work.
@lostluck Could you please help me review it and find out what else should I do? I'm glad to work on it. :)
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] Mention the appropriate issue in your description (for example: `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, comment `fixes #<ISSUE NUMBER>` instead.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/get-started-contributing/#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on a diff in pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on code in PR #25203:
URL: https://github.com/apache/beam/pull/25203#discussion_r1089572178
##########
sdks/go/pkg/beam/core/funcx/sideinput.go:
##########
@@ -91,6 +91,9 @@ func unfoldIter(t reflect.Type) ([]reflect.Type, bool, error) {
if ok, err := isOutParam(t.In(i)); !ok {
return nil, false, errors.Wrap(err, errIllegalParametersInIter)
}
+ if t.In(i).Elem().Kind() == reflect.Interface{
+ panic("Type interface{} isn't a supported PCollection type")
Review Comment:
Same here, don't panic, check for something more specific.
##########
sdks/go/pkg/beam/core/funcx/output.go:
##########
@@ -84,6 +84,9 @@ func unfoldEmit(t reflect.Type) ([]reflect.Type, bool, error) {
if ok, err := isInParam(t.In(i)); !ok {
return nil, false, errors.Wrap(err, errIllegalParametersInEmit)
}
+ if t.In(i).Kind() == reflect.Interface || (t.In(i).Kind() == reflect.Pointer && t.In(i).Elem().Kind() == reflect.Interface) {
Review Comment:
Checking the Kind() against reflect.Interface is a good first approximation, but this prevents *all* interfaces from appearing in types in beam.
The problem the issue needs to address isn't "no interfaces are allowed ever" but "the vanilla empty interface{}" isn't allowed.
But care needs to be taken: Not all "empty interfaces" are created equally. Since BeamGo was developed before Go Generics, we needed some way of simulating that kind of behavior. We called these "Universal Types".
Universal types are lightly described in the design RFC here:
https://s.apache.org/beam-go-sdk-design-rfc#heading=h.1vovlxln20bf
You can detect universal types with the function `typex.IsUniversal()`: https://github.com/apache/beam/blob/master/sdks/go/pkg/beam/core/typex/class.go#L224
Look at how "IsUniversal" is defined, and how the different universal types are defined.
----
Further, we do allow arbitary interface types in these various function type signatures, but we require them to have a coder registered with Beam. That validation necessarily happens at a later stage, to avoid unnecessary coupling and complications at early parts of validation.
Since the empty interface can't have a coder defined for it (everything satisfies the empty interface), it's simpler to not allow it.
----
Then you can see that what we want to do for this bug is compare the type against the type of the empty interface.
```
var anyType = reflect.TypeOf((*any)(nil)).Elem()
```
(`any` is an alias for `interface{}`).
Let me know if you have questions about this.
##########
sdks/go/pkg/beam/core/funcx/output.go:
##########
@@ -84,6 +84,9 @@ func unfoldEmit(t reflect.Type) ([]reflect.Type, bool, error) {
if ok, err := isInParam(t.In(i)); !ok {
return nil, false, errors.Wrap(err, errIllegalParametersInEmit)
}
+ if t.In(i).Kind() == reflect.Interface || (t.In(i).Kind() == reflect.Pointer && t.In(i).Elem().Kind() == reflect.Interface) {
+ panic("Type interface{} isn't a supported PCollection type")
Review Comment:
If there's an error return, one should return an error instead of panicking. Panicking is generally a last resort thing, and rarely when one can return an error instead.
##########
sdks/go/pkg/beam/io/parquetio/parquetio.go:
##########
@@ -149,7 +149,7 @@ type parquetWriteFn struct {
Filename string `json:"filename"`
}
-func (a *parquetWriteFn) ProcessElement(ctx context.Context, _ int, iter func(*any) bool) error {
+func (a *parquetWriteFn) ProcessElement(ctx context.Context, _ int, iter func(*beam.X) bool) error {
Review Comment:
This is the correct fix! No notes here.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on a diff in pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on code in PR #25203:
URL: https://github.com/apache/beam/pull/25203#discussion_r1108036547
##########
sdks/go/pkg/beam/core/funcx/sideinput_test.go:
##########
@@ -39,6 +39,7 @@ func TestIsIter(t *testing.T) {
{func(*typex.EventTime, *int, *string) bool { return false }, false}, // EventTimes disallowed
{func(*int, *typex.Y, *typex.Z) bool { return false }, false}, // too many values
{func(*typex.EventTime, *int, *typex.Y, *typex.Z) bool { return false }, false}, // too many values, EventTimes disallowed
+ {func(any) bool { return false }, false}, // any is not allowed as a param
Review Comment:
Great question and point!
Yes emitter functions can take pointer elements. And similarly, since the iterator function parameter is the pointer to an element type, you can pass in a pointer to a pointer.
Those would be `func(*any)` and `func(**any) bool`
Pointers to pointers are generally rare in Go, but it's consistent with the intended handling. If Go develops a standard approach to iterators, we'd also support that more directly, and hopefully avoid the ** question.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] yyy1000 commented on a diff in pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "yyy1000 (via GitHub)" <gi...@apache.org>.
yyy1000 commented on code in PR #25203:
URL: https://github.com/apache/beam/pull/25203#discussion_r1089623120
##########
sdks/go/pkg/beam/core/funcx/output.go:
##########
@@ -84,6 +84,9 @@ func unfoldEmit(t reflect.Type) ([]reflect.Type, bool, error) {
if ok, err := isInParam(t.In(i)); !ok {
return nil, false, errors.Wrap(err, errIllegalParametersInEmit)
}
+ if t.In(i).Kind() == reflect.Interface || (t.In(i).Kind() == reflect.Pointer && t.In(i).Elem().Kind() == reflect.Interface) {
Review Comment:
Thanks a lot! I'm clearer about this now.
Does it mean we should not allow empty interfaces like "interface{}", but we do allow 'Universal Types'?
But I still have a question is that, if a function has a param with "interface{}", like that
```
Fn := func(interface{}){}
t := reflect.TypeOf(Fn)
```
but typex.ClassOf(t.In(0)) returns "Concrete", I ought to think it will return "Universal".
The type system is a bit complex, I'm still learning it. :)
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on a diff in pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on code in PR #25203:
URL: https://github.com/apache/beam/pull/25203#discussion_r1089568225
##########
sdks/go/pkg/beam/core/funcx/output.go:
##########
@@ -84,6 +84,9 @@ func unfoldEmit(t reflect.Type) ([]reflect.Type, bool, error) {
if ok, err := isInParam(t.In(i)); !ok {
return nil, false, errors.Wrap(err, errIllegalParametersInEmit)
}
+ if t.In(i).Kind() == reflect.Interface || (t.In(i).Kind() == reflect.Pointer && t.In(i).Elem().Kind() == reflect.Interface) {
+ panic("Type interface{} isn't a supported PCollection type")
Review Comment:
If there's an error return, one should return an error instead of panicking. Panicking is generally a last resort thing, and rarely when one can return an error instead.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] github-actions[bot] commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1416736619
Reminder, please take a look at this pr: @riteshghorse @Abacn
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on a diff in pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on code in PR #25203:
URL: https://github.com/apache/beam/pull/25203#discussion_r1102041421
##########
sdks/go/pkg/beam/core/funcx/output.go:
##########
@@ -84,6 +84,9 @@ func unfoldEmit(t reflect.Type) ([]reflect.Type, bool, error) {
if ok, err := isInParam(t.In(i)); !ok {
return nil, false, errors.Wrap(err, errIllegalParametersInEmit)
}
+ if t.In(i).Kind() == reflect.Interface || (t.In(i).Kind() == reflect.Pointer && t.In(i).Elem().Kind() == reflect.Interface) {
Review Comment:
Yes. Exactly. Deny "interface{}" but allow `beam.T` et al.
The "universal" types should only be referring to `beam.T` etc. Not arbitrary interfaces. Basically, it's important to distinguish between them (`beam.T` is not `beam.U`) so that for example, if a function is dropping a key or a value in a DoFn, we know which one is being used downstream./
Users can use beam.T and similar to escape the type system, but then they deserve any runtime type errors they get at pipeline execution time. The strictness of knowing what types are used where is to help users avoid expensive execution time issues.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] riteshghorse commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "riteshghorse (via GitHub)" <gi...@apache.org>.
riteshghorse commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1430111868
@yyy1000 I think the check is failing because new line is missing at the end of `pkg/beam/runners/prism/internal/config/config.go`
`pkg/beam/runners/prism/internal/urns/urns_test.go`
Not a part of your PR though. You may want to sync you branch with master and re-running `go fmt ./...`
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] yyy1000 commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "yyy1000 (via GitHub)" <gi...@apache.org>.
yyy1000 commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1430807328
Got it!
I will add these tests today.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] github-actions[bot] commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1422500768
Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment `assign to next reviewer`:
R: @damccorm for label go.
R: @johnjcasey for label io.
Available commands:
- `stop reviewer notifications` - opt out of the automated review tooling
- `remind me after tests pass` - tag the comment author after tests pass
- `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1422648127
Ah that's what happened. When it was undrafted it feel off my review slate.
Looking at this today.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck merged pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck merged PR #25203:
URL: https://github.com/apache/beam/pull/25203
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on a diff in pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on code in PR #25203:
URL: https://github.com/apache/beam/pull/25203#discussion_r1107736060
##########
sdks/go/pkg/beam/core/funcx/sideinput_test.go:
##########
@@ -39,6 +39,7 @@ func TestIsIter(t *testing.T) {
{func(*typex.EventTime, *int, *string) bool { return false }, false}, // EventTimes disallowed
{func(*int, *typex.Y, *typex.Z) bool { return false }, false}, // too many values
{func(*typex.EventTime, *int, *typex.Y, *typex.Z) bool { return false }, false}, // too many values, EventTimes disallowed
+ {func(any) bool { return false }, false}, // any is not allowed as a param
Review Comment:
Nit, this needs to be *any since these iterator functions always take the pointer to the value, not the value itself.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1430164071
Whoops. That's my bad.
The GitHub unit test action has been broken so these slipped in. I'll be
handling them today.
On Tue, Feb 14, 2023, 9:24 AM Ritesh Ghorse ***@***.***>
wrote:
> @yyy1000 <https://github.com/yyy1000> I think the check is failing
> because new line is missing at the end of
> pkg/beam/runners/prism/internal/config/config.go
> pkg/beam/runners/prism/internal/urns/urns_test.go
>
> Not a part of your PR though. You may want to sync you branch with master
> and re-running go fmt ./...
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/apache/beam/pull/25203#issuecomment-1430111868>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ADKDOFKJPYC6Y4JRJX3WDIDWXO5VHANCNFSM6AAAAAAUIY2EL4>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1422648467
R:@lostluck
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on a diff in pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on code in PR #25203:
URL: https://github.com/apache/beam/pull/25203#discussion_r1089568225
##########
sdks/go/pkg/beam/core/funcx/output.go:
##########
@@ -84,6 +84,9 @@ func unfoldEmit(t reflect.Type) ([]reflect.Type, bool, error) {
if ok, err := isInParam(t.In(i)); !ok {
return nil, false, errors.Wrap(err, errIllegalParametersInEmit)
}
+ if t.In(i).Kind() == reflect.Interface || (t.In(i).Kind() == reflect.Pointer && t.In(i).Elem().Kind() == reflect.Interface) {
+ panic("Type interface{} isn't a supported PCollection type")
Review Comment:
If there's an error return, one should return an error instead of panicking. Panicking is generally a last resort thing, and rarely when one can return an error instead.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] yyy1000 commented on a diff in pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "yyy1000 (via GitHub)" <gi...@apache.org>.
yyy1000 commented on code in PR #25203:
URL: https://github.com/apache/beam/pull/25203#discussion_r1102187994
##########
sdks/go/pkg/beam/core/funcx/output.go:
##########
@@ -84,8 +84,9 @@ func unfoldEmit(t reflect.Type) ([]reflect.Type, bool, error) {
if ok, err := isInParam(t.In(i)); !ok {
return nil, false, errors.Wrap(err, errIllegalParametersInEmit)
}
- if t.In(i).Kind() == reflect.Interface || (t.In(i).Kind() == reflect.Pointer && t.In(i).Elem().Kind() == reflect.Interface) {
- panic("Type interface{} isn't a supported PCollection type")
+ emptyInterface := reflect.TypeOf((*any)(nil)).Elem()
Review Comment:
Oh, got it! Thanks! I changed it.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] yyy1000 commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "yyy1000 (via GitHub)" <gi...@apache.org>.
yyy1000 commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1432607554
So far it's close to finished.😩
It seems that I made a lot of mistakes during the process, and I will do better next time.
Thank you for your patient guidance. :)
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1433652931
Run Go Portable PreCommit
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1433654645
Run GoPortable PreCommit
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] yyy1000 commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "yyy1000 (via GitHub)" <gi...@apache.org>.
yyy1000 commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1430814800
I have added an additional test case for each and comments.
May these comments be fitting.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] yyy1000 commented on a diff in pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "yyy1000 (via GitHub)" <gi...@apache.org>.
yyy1000 commented on code in PR #25203:
URL: https://github.com/apache/beam/pull/25203#discussion_r1107909513
##########
sdks/go/pkg/beam/core/funcx/sideinput_test.go:
##########
@@ -39,6 +39,7 @@ func TestIsIter(t *testing.T) {
{func(*typex.EventTime, *int, *string) bool { return false }, false}, // EventTimes disallowed
{func(*int, *typex.Y, *typex.Z) bool { return false }, false}, // too many values
{func(*typex.EventTime, *int, *typex.Y, *typex.Z) bool { return false }, false}, // too many values, EventTimes disallowed
+ {func(any) bool { return false }, false}, // any is not allowed as a param
Review Comment:
😫So sorry for that.
I have fixed it.
Another question is: can 'emit function' take both pointer and non-pointer as params? If it can, I will add test cases for *any and any in output_test.go.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] yyy1000 commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "yyy1000 (via GitHub)" <gi...@apache.org>.
yyy1000 commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1407280156
Thank you very much!😊
I have made changes according to your advice, but I'm not sure I do it well. Your comments are very helpful but I may still make some mistakes because I'm not so familiar with the project now.
Could you please review it again?
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] yyy1000 commented on pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "yyy1000 (via GitHub)" <gi...@apache.org>.
yyy1000 commented on PR #25203:
URL: https://github.com/apache/beam/pull/25203#issuecomment-1425933104
Pretty strange. I run go fmt on these files but the check still fails. 🤔
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] yyy1000 commented on a diff in pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "yyy1000 (via GitHub)" <gi...@apache.org>.
yyy1000 commented on code in PR #25203:
URL: https://github.com/apache/beam/pull/25203#discussion_r1108068105
##########
sdks/go/pkg/beam/core/funcx/sideinput_test.go:
##########
@@ -39,6 +39,7 @@ func TestIsIter(t *testing.T) {
{func(*typex.EventTime, *int, *string) bool { return false }, false}, // EventTimes disallowed
{func(*int, *typex.Y, *typex.Z) bool { return false }, false}, // too many values
{func(*typex.EventTime, *int, *typex.Y, *typex.Z) bool { return false }, false}, // too many values, EventTimes disallowed
+ {func(any) bool { return false }, false}, // any is not allowed as a param
Review Comment:
Thanks!
I made add one line of code for *any in the emitter.
I think we can make future changes if Go could develop a standard approach to iterators.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on a diff in pull request #25203: Fix interface{} in iter& emit type of DoFn in Go
Posted by "lostluck (via GitHub)" <gi...@apache.org>.
lostluck commented on code in PR #25203:
URL: https://github.com/apache/beam/pull/25203#discussion_r1102042807
##########
sdks/go/pkg/beam/core/funcx/output.go:
##########
@@ -84,8 +84,9 @@ func unfoldEmit(t reflect.Type) ([]reflect.Type, bool, error) {
if ok, err := isInParam(t.In(i)); !ok {
return nil, false, errors.Wrap(err, errIllegalParametersInEmit)
}
- if t.In(i).Kind() == reflect.Interface || (t.In(i).Kind() == reflect.Pointer && t.In(i).Elem().Kind() == reflect.Interface) {
- panic("Type interface{} isn't a supported PCollection type")
+ emptyInterface := reflect.TypeOf((*any)(nil)).Elem()
Review Comment:
feel free to declare this outside the function so it's only done once, rather than every time the method is called.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org