derrickaw commented on code in PR #35692:
URL: https://github.com/apache/beam/pull/35692#discussion_r2233566447


##########
sdks/python/apache_beam/transforms/core.py:
##########
@@ -3962,9 +3963,46 @@ def to_runner_api_parameter(self, context):
   def infer_output_type(self, unused_input_type):
     if not self.values:
       return typehints.Any
-    return typehints.Union[[
-        trivial_inference.instance_to_type(v) for v in self.values
-    ]]
+
+    try:
+      if not all(isinstance(v, pvalue.Row) for v in self.values):
+        raise TypeError("All data must be Rows.")
+      first_fields = self.values[0].as_dict().keys()
+      if not all(v.as_dict().keys() == first_fields for v in self.values):
+        raise TypeError("All rows must have the same fields.")
+    except (TypeError, AttributeError):
+      # For non-Row or inconsistent rows.
+      return typehints.Union[[
+          trivial_inference.instance_to_type(v) for v in self.values
+      ]]
+
+    # Save field types for each field

Review Comment:
   done, 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.

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