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/09/16 16:00:01 UTC

[GitHub] [beam] robertwb commented on a change in pull request #12832: [BEAM-10906] Add basic ToRows transform.

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



##########
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:
       Good call. Done.

##########
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:
       Done. All looks 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