From 6561abf7beb3d19e4ff4fa9726c4351b9019c1ab Mon Sep 17 00:00:00 2001 From: Christoph Grotz Date: Thu, 3 Oct 2024 17:37:56 +0200 Subject: [PATCH] Update groupbykey.py (#32359) The original example was not actually counting the produce but grouping the produce per season. Maybe it's better to rename the variables to reflect this, in order to not confuse the reader. --- .../snippets/transforms/aggregation/groupbykey.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey.py b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey.py index aca39f6a2190..a2d32b564a3a 100644 --- a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey.py +++ b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupbykey.py @@ -40,9 +40,9 @@ def groupbykey(test=None): import apache_beam as beam with beam.Pipeline() as pipeline: - produce_counts = ( + produce_per_season = ( pipeline - | 'Create produce counts' >> beam.Create([ + | 'Create produce list' >> beam.Create([ ('spring', '🍓'), ('spring', '🥕'), ('spring', '🍆'), @@ -54,12 +54,12 @@ def groupbykey(test=None): ('fall', '🍅'), ('winter', '🍆'), ]) - | 'Group counts per produce' >> beam.GroupByKey() + | 'Group produce per season' >> beam.GroupByKey() | beam.MapTuple(lambda k, vs: (k, sorted(vs))) # sort and format | beam.Map(print)) # [END groupbykey] if test: - test(produce_counts) + test(produce_per_season) if __name__ == '__main__':