udim commented on a change in pull request #12832:
URL: https://github.com/apache/beam/pull/12832#discussion_r489114329



##########
File path: sdks/python/apache_beam/transforms/core.py
##########
@@ -2519,6 +2520,45 @@ def expand(self, pcoll):
             (*(key + value))))
 
 
+class ToRows(PTransform):
+  """Converts the elements of a PCollection into a schema'd PCollection of 
Rows.
+
+  `ToRow(...)` is roughly equivalent to `Map(lambda x: Row(...))` where each
+  argument (which may be a string or callable) of `ToRow` is applied to `x`.
+  For example,
+
+      pcoll | beam.ToRow('a', b=lambda x: foo(x))

Review comment:
       Nit: For simplicity I'd only support the kwargs format.
   (My personal preference would be to always use kwargs so it's clear what's 
being mapped to what.)

##########
File path: sdks/python/apache_beam/typehints/trivial_inference.py
##########
@@ -320,6 +325,10 @@ def infer_return_type(c, input_types, debug=False, 
depth=5):
             dict: typehints.Dict[Any, Any]
         }[c]
       return c
+    elif (c == getattr and len(input_types) == 2 and

Review comment:
       I recommend testing internally since this may break some tests.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to