[
https://issues.apache.org/jira/browse/BEAM-3126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16337985#comment-16337985
]
ASF GitHub Bot commented on BEAM-3126:
--------------------------------------
robertwb closed pull request #4463: [BEAM-3126] Adding a new Flatten test to
Python SDK.
URL: https://github.com/apache/beam/pull/4463
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/sdks/python/apache_beam/transforms/ptransform_test.py
b/sdks/python/apache_beam/transforms/ptransform_test.py
index fb20d8c4e9b..09ac72b36e1 100644
--- a/sdks/python/apache_beam/transforms/ptransform_test.py
+++ b/sdks/python/apache_beam/transforms/ptransform_test.py
@@ -535,6 +535,24 @@ def
test_flatten_input_type_must_be_iterable_of_pcolls(self):
with self.assertRaises(TypeError):
set([1, 2, 3]) | beam.Flatten()
+ @attr('ValidatesRunner')
+ def test_flatten_multiple_pcollections_having_multiple_consumers(self):
+ pipeline = TestPipeline()
+ input = pipeline | 'Start' >> beam.Create(['AA', 'BBB', 'CC'])
+
+ def split_even_odd(element):
+ tag = 'even_length' if len(element) % 2 == 0 else 'odd_length'
+ return pvalue.TaggedOutput(tag, element)
+
+ even_length, odd_length = (input | beam.Map(split_even_odd)
+ .with_outputs('even_length', 'odd_length'))
+ merged = (even_length, odd_length) | 'Flatten' >> beam.Flatten()
+
+ assert_that(merged, equal_to(['AA', 'BBB', 'CC']))
+ assert_that(even_length, equal_to(['AA', 'CC']), label='assert:even')
+ assert_that(odd_length, equal_to(['BBB']), label='assert:odd')
+ pipeline.run()
+
def test_co_group_by_key_on_list(self):
pipeline = TestPipeline()
pcoll_1 = pipeline | 'Start 1' >> beam.Create(
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Portable flattens in Python SDK Harness
> ---------------------------------------
>
> Key: BEAM-3126
> URL: https://issues.apache.org/jira/browse/BEAM-3126
> Project: Beam
> Issue Type: Sub-task
> Components: sdk-py-harness
> Reporter: Daniel Oliveira
> Assignee: Daniel Oliveira
> Priority: Major
> Labels: portability
>
> Get flattens working for portability in Python SDK Harness.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)