[
https://issues.apache.org/jira/browse/BEAM-6695?focusedWorklogId=235565&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-235565
]
ASF GitHub Bot logged work on BEAM-6695:
----------------------------------------
Author: ASF GitHub Bot
Created on: 30/Apr/19 22:17
Start Date: 30/Apr/19 22:17
Worklog Time Spent: 10m
Work Description: aaltay commented on pull request #8206: [BEAM-6695]
Latest PTransform for Python SDK
URL: https://github.com/apache/beam/pull/8206#discussion_r279955243
##########
File path: sdks/python/apache_beam/transforms/combiners_test.py
##########
@@ -392,5 +394,112 @@ def test_global_fanout(self):
assert_that(result, equal_to([49.5]))
+class LatestTest(unittest.TestCase):
+
+ def test_globally(self):
+ l = [window.GlobalWindows.windowed_value(3, 100),
+ window.GlobalWindows.windowed_value(1, 200),
+ window.GlobalWindows.windowed_value(2, 300)]
+ with TestPipeline() as p:
+ pc = p | Create(l)
+ latest = pc | combine.Latest.Globally()
+ assert_that(latest, equal_to([2]))
+
+ def test_globally_empty(self):
+ l = []
+ with TestPipeline() as p:
+ pc = p | Create(l)
+ latest = pc | combine.Latest.Globally()
+ assert_that(latest, equal_to([None]))
+
+ def test_per_key(self):
+ l = [window.GlobalWindows.windowed_value(('a', 1), 300),
+ window.GlobalWindows.windowed_value(('b', 3), 100),
+ window.GlobalWindows.windowed_value(('a', 2), 200)]
+ with TestPipeline() as p:
+ pc = p | Create(l)
+ latest = pc | combine.Latest.PerKey()
+ assert_that(latest, equal_to([('a', 1), ('b', 3)]))
+
+ def test_per_key_empty(self):
+ l = []
+ with TestPipeline() as p:
+ pc = p | Create(l)
+ latest = pc | combine.Latest.PerKey()
+ assert_that(latest, equal_to([]))
+
+ def test_per_key_add_timestamp_element_type_violation(self):
+ l_int = [window.GlobalWindows.windowed_value(1, 300),
+ window.GlobalWindows.windowed_value(6, 900),
+ window.GlobalWindows.windowed_value(8, 500)]
+ l_dict = [window.GlobalWindows.windowed_value({'a': 5}, 200),
+ window.GlobalWindows.windowed_value({'b': 3}, 300),
+ window.GlobalWindows.windowed_value({'a': 8}, 100)]
+ l_3_tuple = [window.GlobalWindows.windowed_value((1, 2, 3), 800),
+ window.GlobalWindows.windowed_value((4, 5, 6), 200),
+ window.GlobalWindows.windowed_value((7, 8, 9), 700)]
+
+ with self.assertRaises(TypeCheckError):
+ with TestPipeline() as p:
+ pc = p | Create(l_int)
+ _ = pc | beam.ParDo(combine.Latest.PerKey.add_timestamp)
+
+ with self.assertRaises(TypeCheckError):
Review comment:
What is being tested here? Why passing KV values here will result in an
assert?
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 235565)
Time Spent: 6h 50m (was: 6h 40m)
> Latest transform for Python SDK
> -------------------------------
>
> Key: BEAM-6695
> URL: https://issues.apache.org/jira/browse/BEAM-6695
> Project: Beam
> Issue Type: New Feature
> Components: sdk-py-core
> Reporter: Ahmet Altay
> Assignee: Tanay Tummalapalli
> Priority: Minor
> Time Spent: 6h 50m
> Remaining Estimate: 0h
>
> Add a PTransform} and Combine.CombineFn for computing the latest element in a
> PCollection.
> It should offer the same API as its Java counterpart:
> https://github.com/apache/beam/blob/11a977b8b26eff2274d706541127c19dc93131a2/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Latest.java
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)