You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/06/23 21:41:01 UTC
[GitHub] [beam] damondouglas opened a new pull request #12066: [BEAM-9679] Add Side Output to Core Transform Go SDK katas
damondouglas opened a new pull request #12066:
URL: https://github.com/apache/beam/pull/12066
This pull requests adds a Side Output lesson to the Go SDK katas. I would like to request the following reviewers:
(R: @lostluck )
(R: @henryken )
If accepted by both reviewers, please wait until the [Stepik course](https://stepik.org/course/70387) is updated before finally merging this PR.
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [x] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
- [x] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
- [ ] 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/#make-reviewers-job-easier).
Post-Commit Tests Status (on master branch)
------------------------------------------------------------------------------------------------
Lang | SDK | Dataflow | Flink | Samza | Spark
--- | --- | --- | --- | --- | ---
Go | [](https://ci-beam.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/) | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/) | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/)
Java | [](https://ci-beam.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow_Java11/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink_Java11/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming/lastCompletedBuild/)
Python | [](https://ci-beam.apache.org/job/beam_PostCommit_Python2/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Python35/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Python36/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Python37/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Py_VR_Dataflow/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Py_VR_Dataflow_V2/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Py_ValCont/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Python2_PVR_Flink_Cron/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Python35_VR_Flink/lastCompletedBuild/) | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_Python_VR_Spark/lastCompletedBuild/)
XLang | --- | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Flink/lastCompletedBuild/) | --- | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Spark/lastCompletedBuild/)
Pre-Commit Tests Status (on master branch)
------------------------------------------------------------------------------------------------
--- |Java | Python | Go | Website
--- | --- | --- | --- | ---
Non-portable | [](https://ci-beam.apache.org/job/beam_PreCommit_Java_Cron/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Python_Cron/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Cron/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Go_Cron/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Website_Cron/lastCompletedBuild/)
Portable | --- | [](https://ci-beam.apache.org/job/beam_PreCommit_Portable_Python_Cron/lastCompletedBuild/) | --- | ---
See [.test-infra/jenkins/README](https://github.com/apache/beam/blob/master/.test-infra/jenkins/README.md) for trigger phrase, status and link of all Jenkins jobs.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on a change in pull request #12066: [BEAM-9679] Add Side Output to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
lostluck commented on a change in pull request #12066:
URL: https://github.com/apache/beam/pull/12066#discussion_r446321991
##########
File path: learning/katas/go/Core Transforms/Side Output/Side Output/pkg/task/task.go
##########
@@ -0,0 +1,30 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package task
+
+import (
+ "github.com/apache/beam/sdks/go/pkg/beam"
+)
+
+func ApplyTransform(s beam.Scope, input beam.PCollection) (beam.PCollection, beam.PCollection) {
+ return beam.ParDo2(s, func(element int, numBelow100, numAbove100 func(int)) {
+ if element <= 100 {
+ numBelow100(element)
+ return
+ }
+ numAbove100(element)
Review comment:
As written this is idiomatic 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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] henryken commented on a change in pull request #12066: [BEAM-9679] Add Additional Outputs Lesson to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
henryken commented on a change in pull request #12066:
URL: https://github.com/apache/beam/pull/12066#discussion_r446475735
##########
File path: learning/katas/go/Core Transforms/Additional Outputs/Additional Outputs/task.md
##########
@@ -16,12 +16,10 @@
~ limitations under the License.
-->
-# Side Output
+# Additional Outputs
-While ParDo always produces a main output PCollection (as the return value from apply), you can
Review comment:
This paragraph is actually from the Beam Programming Guide.
https://beam.apache.org/documentation/programming-guide/#additional-outputs
Probably should consider revising the guide as well if it's not accurate, e.g. main output.
FYI, historically it used to be called Side Output.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] damondouglas commented on pull request #12066: [BEAM-9679] Add Additional Outputs Lesson to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
damondouglas commented on pull request #12066:
URL: https://github.com/apache/beam/pull/12066#issuecomment-650648875
@lostluck / @henryken I've updated [the stepik course](https://stepik.org/course/70387) and committed the modified `*-remote.yaml` files to this PR. It is ready to merge.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on a change in pull request #12066: [BEAM-9679] Add Additional Outputs Lesson to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
lostluck commented on a change in pull request #12066:
URL: https://github.com/apache/beam/pull/12066#discussion_r446579704
##########
File path: learning/katas/go/Core Transforms/Additional Outputs/Additional Outputs/task.md
##########
@@ -16,12 +16,10 @@
~ limitations under the License.
-->
-# Side Output
+# Additional Outputs
-While ParDo always produces a main output PCollection (as the return value from apply), you can
Review comment:
I remember. Side Output was a historical holdover from the original Dataflow API, and by the nature of how extra outputs are handled by the Java SDK. Thanks!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] henryken commented on a change in pull request #12066: [BEAM-9679] Add Additional Outputs Lesson to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
henryken commented on a change in pull request #12066:
URL: https://github.com/apache/beam/pull/12066#discussion_r446475760
##########
File path: learning/katas/go/Core Transforms/Additional Outputs/Additional Outputs/task.md
##########
@@ -16,12 +16,10 @@
~ limitations under the License.
-->
-# Side Output
+# Additional Outputs
-While ParDo always produces a main output PCollection (as the return value from apply), you can
Review comment:
I'll revise the name in other Katas as well
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] damondouglas commented on a change in pull request #12066: [BEAM-9679] Add Side Output to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
damondouglas commented on a change in pull request #12066:
URL: https://github.com/apache/beam/pull/12066#discussion_r446431656
##########
File path: learning/katas/go/Core Transforms/Side Output/Side Output/pkg/task/task.go
##########
@@ -0,0 +1,30 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package task
+
+import (
+ "github.com/apache/beam/sdks/go/pkg/beam"
+)
+
+func ApplyTransform(s beam.Scope, input beam.PCollection) (beam.PCollection, beam.PCollection) {
+ return beam.ParDo2(s, func(element int, numBelow100, numAbove100 func(int)) {
+ if element <= 100 {
+ numBelow100(element)
+ return
+ }
+ numAbove100(element)
Review comment:
I will keep this unchanged then. Thank you.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on pull request #12066: [BEAM-9679] Add Side Output to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
lostluck commented on pull request #12066:
URL: https://github.com/apache/beam/pull/12066#issuecomment-649618663
I have not forgotten about this PR, I'm unfortunately a bit distrcted until later this afternoon. I should be able to get to it then. Thank you for your patience!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] damondouglas commented on pull request #12066: [BEAM-9679] Add Additional Outputs Lesson to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
damondouglas commented on pull request #12066:
URL: https://github.com/apache/beam/pull/12066#issuecomment-650466172
Thank you, Robert. @henryken This has significantly changed since you agreed with it earlier aside from the `else` syntax. I just wanted to make sure you were ok before I updated Stepik. Of course any recommended changes are more than welcome from you.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] henryken commented on a change in pull request #12066: [BEAM-9679] Add Additional Outputs Lesson to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
henryken commented on a change in pull request #12066:
URL: https://github.com/apache/beam/pull/12066#discussion_r446475760
##########
File path: learning/katas/go/Core Transforms/Additional Outputs/Additional Outputs/task.md
##########
@@ -16,12 +16,10 @@
~ limitations under the License.
-->
-# Side Output
+# Additional Outputs
-While ParDo always produces a main output PCollection (as the return value from apply), you can
Review comment:
I'll revise the name in other Katas as well to make it consistent.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] damondouglas commented on pull request #12066: [BEAM-9679] Add Side Output to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
damondouglas commented on pull request #12066:
URL: https://github.com/apache/beam/pull/12066#issuecomment-649865228
No problem at all. Please take your time and thank you.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] henryken commented on a change in pull request #12066: [BEAM-9679] Add Side Output to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
henryken commented on a change in pull request #12066:
URL: https://github.com/apache/beam/pull/12066#discussion_r445934652
##########
File path: learning/katas/go/Core Transforms/Side Output/Side Output/pkg/task/task.go
##########
@@ -0,0 +1,30 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package task
+
+import (
+ "github.com/apache/beam/sdks/go/pkg/beam"
+)
+
+func ApplyTransform(s beam.Scope, input beam.PCollection) (beam.PCollection, beam.PCollection) {
+ return beam.ParDo2(s, func(element int, numBelow100, numAbove100 func(int)) {
+ if element <= 100 {
+ numBelow100(element)
+ return
+ }
+ numAbove100(element)
Review comment:
While this works too, maybe you would want to consider using `else` statement.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on pull request #12066: [BEAM-9679] Add Additional Outputs Lesson to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
lostluck commented on pull request #12066:
URL: https://github.com/apache/beam/pull/12066#issuecomment-650649838
Thanks! Have a good weekend.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck commented on a change in pull request #12066: [BEAM-9679] Add Side Output to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
lostluck commented on a change in pull request #12066:
URL: https://github.com/apache/beam/pull/12066#discussion_r446333101
##########
File path: learning/katas/go/Core Transforms/Side Output/Side Output/task.md
##########
@@ -0,0 +1,50 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+# Side Output
+
+While ParDo always produces a main output PCollection (as the return value from apply), you can
+also have your ParDo produce any number of additional output PCollections. If you choose to have
+multiple outputs, your ParDo returns all of the output PCollections (including the main output)
+bundled together.
Review comment:
What's the "main output" ? Consider removing the paranthetical, I don't think it adds anything.
DoFns in BeamGo don't have a "main" output, and we do not use that term in the GoDoc (which has problems, but this isn't one of them). They have the first, second, third etc outputs. DoFn return outputs only have two properties, if present, they're always the first one, and they require the DoFn to always return an element (or abort with an error).
##########
File path: learning/katas/go/Core Transforms/Side Output/Side Output/task.md
##########
@@ -0,0 +1,50 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+# Side Output
Review comment:
Overall, my main concern is calling these "Side Outputs" . The Beam model doesn't have Side Outputs, it has multiple or Additional Outputs. https://beam.apache.org/documentation/programming-guide/#additional-outputs
I'd recommend going with Additional Outputs, which is in the programing guide, and the godoc. https://pkg.go.dev/github.com/apache/beam/sdks/go/pkg/beam?tab=doc#hdr-Additional_Outputs
Side Inputs exist distinctly since they don't drive parallel execution, and behave very differently than PCollections used for Parallel input.
Each output however produces a different PCollection, and that's about it. Also calling them Side Outputs ascribes extra semantics that don't exist.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] henryken commented on pull request #12066: [BEAM-9679] Add Additional Outputs Lesson to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
henryken commented on pull request #12066:
URL: https://github.com/apache/beam/pull/12066#issuecomment-650478259
@damondouglas, I find the changes are okay. You may proceed.
I left a comment above.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lostluck merged pull request #12066: [BEAM-9679] Add Additional Outputs Lesson to Core Transform Go SDK katas
Posted by GitBox <gi...@apache.org>.
lostluck merged pull request #12066:
URL: https://github.com/apache/beam/pull/12066
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org