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



##########
File path: sdks/python/apache_beam/transforms/util.py
##########
@@ -741,6 +741,7 @@ def WithKeys(pcoll, k):
 
 @experimental()
 @typehints.with_input_types(Tuple[K, V])
[email protected]_output_types(Tuple[K, List[V]])

Review comment:
       I was thinking it might be Iterable rather than List, so I looked at the 
code and it doesn't seem to group by key at all.
   
   I modified a test from `GroupIntoBatchesTest` to print to elements:
   ```py
     def test_in_global_window(self):
       with TestPipeline() as pipeline:
         def print_elements(e):
           print(e)
           return e
   
         collection = pipeline \
                      | beam.Create(GroupIntoBatchesTest._create_test_data()) \
                      | util.GroupIntoBatches(GroupIntoBatchesTest.BATCH_SIZE) \
                      | beam.Map(print_elements)
   ```
   
   Printout:
   ```py
   [('key', 'Einstein'), ('key', 'Darwin'), ('key', 'Copernicus'), ('key', 
'Pasteur'), ('key', 'Curie')]
   [('key', 'Faraday'), ('key', 'Newton'), ('key', 'Bohr'), ('key', 'Galilei'), 
('key', 'Maxwell')]
   ```




----------------------------------------------------------------
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:
[email protected]


Reply via email to