codeBehindMe commented on a change in pull request #11976:
URL: https://github.com/apache/beam/pull/11976#discussion_r440723127



##########
File path: sdks/go/pkg/beam/pardo.go
##########
@@ -414,7 +412,36 @@ func ParDo6(s Scope, dofn interface{}, col PCollection, 
opts ...Option) (PCollec
 func ParDo7(s Scope, dofn interface{}, col PCollection, opts ...Option) 
(PCollection, PCollection, PCollection, PCollection, PCollection, PCollection, 
PCollection) {
        ret := MustN(TryParDo(s, dofn, col, opts...))
        if len(ret) != 7 {
-               panic(fmt.Sprintf("expected 7 output. Found: %v", ret))
+               panic(formatParDoError(dofn, len(ret), 7))
        }
        return ret[0], ret[1], ret[2], ret[3], ret[4], ret[5], ret[6]
 }
+
+//formatParDoError is a helper function to provide a more concise error
+// message to the users when a DoFn and its ParDo pairing is incorrect.
+//
+// We construct a new graph.Fn using the doFn which is passed. We explicitly
+// ignore the error since we already know that its already a DoFn type as
+// TryParDo would have panicked otherwise.
+func formatParDoError(doFn interface{}, emitSize int, parDoSize int) string {
+       doFun, _ := graph.NewFn(doFn)
+       doFnName := doFun.Name()
+
+       thisParDo := recommendParDo(parDoSize) // Conveniently keeps the API 
slim.

Review comment:
       b31ab3a885




----------------------------------------------------------------
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:
[email protected]


Reply via email to