dianfu commented on code in PR #19696:
URL: https://github.com/apache/flink/pull/19696#discussion_r870898350
##########
flink-python/pyflink/datastream/tests/test_window.py:
##########
@@ -410,6 +411,36 @@ def test_side_output_late_data(self):
side_expected = ['+I[a, 4]']
self.assert_equals_sorted(side_expected, side_sink.get_results())
+ def test_global_window_with_purging_trigger(self):
+ self.env.set_parallelism(1)
+ data_stream = self.env.from_collection([
+ ('hi', 1), ('hi', 1), ('hi', 1), ('hi', 1), ('hi', 1), ('hi', 1),
('hi', 1)],
+ type_info=Types.TUPLE([Types.STRING(), Types.INT()])) # type:
DataStream
+
+ watermark_strategy = WatermarkStrategy.for_monotonous_timestamps() \
+ .with_timestamp_assigner(SecondColumnTimestampAssigner())
+
+ class MyProcessFunction(ProcessWindowFunction):
+
+ def clear(self, context: ProcessWindowFunction.Context) -> None:
+ pass
+
+ def process(self, key, context: ProcessWindowFunction.Context,
+ elements: Iterable[Tuple[str, int]]) ->
Iterable[tuple]:
+ return [(key, len([e for e in elements]))]
+
+ data_stream.assign_timestamps_and_watermarks(watermark_strategy) \
+ .key_by(lambda x: x[0], key_type=Types.STRING()) \
+ .window(GlobalWindows.create()) \
+ .trigger(PurgingTrigger.of(CountTrigger.of(5))) \
Review Comment:
```suggestion
.trigger(PurgingTrigger.of(CountTrigger.of(2))) \
```
Change the size to a smaller value to demonstrate that the purging trigger
worked?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]