shunping commented on code in PR #34897:
URL: https://github.com/apache/beam/pull/34897#discussion_r2082251630


##########
sdks/python/apache_beam/ml/anomaly/transforms.py:
##########
@@ -600,20 +610,43 @@ def expand(
     #
     # We select uuid.uuid1() for its inclusion of node information, making it
     # more suitable for parallel execution environments.
-    add_temp_key_fn: Callable[[InputT], KeyedInputT] \
-        = lambda e: (e[0], (str(uuid.uuid1()), e[1]))
-    keyed_input = (input | "Add temp key" >> beam.Map(add_temp_key_fn))
 
+    if isinstance(input.element_type, TupleConstraint):
+      keyed_input = input
+    else:
+      # Add a None key if the input is unkeyed.
+      keyed_input = input | beam.WithKeys(None)

Review Comment:
   Sure, I agree with you on this. Let me change that to a solid value 0.



-- 
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