hjtran commented on code in PR #35874:
URL: https://github.com/apache/beam/pull/35874#discussion_r2279560154


##########
sdks/python/apache_beam/transforms/core.py:
##########
@@ -3849,6 +3849,15 @@ def _extract_input_pvalues(self, pvalueish):
       raise ValueError(
           'Input to Flatten must be an iterable. '
           'Got a value of type %s instead.' % type(pvalueish))
+
+    # Spot check to see if any of the items are iterables of PCollections
+    # and raise an error if so. This is always a user-error
+    for idx, item in enumerate(pvalueish):
+      if (isinstance(item, typing.Sequence) and len(item) and
+          isinstance(item[0], pvalue.PCollection)):
+        raise TypeError(
+            'Inputs to Flatten cannot include an iterable of PCollections. '
+            f'(input at index {idx}: "{item}")')

Review Comment:
   I intentionally only chose to sample the first element to save time in case 
there were any especially large sequences and I figure most actual scenarios 
where this happens it'll be a homogenous list.
   
   @liferoad what do you think, is it worth checking the entire sequence?



-- 
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-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to