New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-19403][python] Support Pandas Stream Group Window Aggregation #13483
Conversation
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit cceb5e9 (Fri Feb 19 07:28:25 UTC 2021) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
c89615b
to
8516cca
Compare
@@ -259,6 +261,128 @@ def test_over_window_aggregate_function(self): | |||
"3,2.0,3,2.0,1.0,1.0,2.0,2.0,1.0,1.0"]) | |||
|
|||
|
|||
class StreamPandasUDAFITTests(PyFlinkBlinkStreamTableTestCase): | |||
def test_group_window_aggregate_function_over_time(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_group_window_aggregate_function_over_time(self): | |
def test_sliding_group_window_over_time(self): |
"3,2018-03-11 02:30:00.0,2018-03-11 03:30:00.0,2.0"]) | ||
os.remove(source_path) | ||
|
||
def test_group_window_aggregate_function_over_count(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_group_window_aggregate_function_over_count(self): | |
def test_sliding_group_window_over_count(self): |
/** | ||
* For serializing the window in checkpoints. | ||
*/ | ||
private TypeSerializer<W> windowSerializer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private TypeSerializer<W> windowSerializer; | |
private transient TypeSerializer<W> windowSerializer; |
private void emitWindowResult(W window) throws Exception { | ||
windowAccumulateData.setCurrentNamespace(window); | ||
windowRetractData.setCurrentNamespace(window); | ||
Iterable<RowData> currentWindowAccumulateDatas = windowAccumulateData.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iterable<RowData> currentWindowAccumulateDatas = windowAccumulateData.get(); | |
Iterable<RowData> currentWindowAccumulateData = windowAccumulateData.get(); |
if (currentWindowAccumulateDatas != null) { | ||
currentBatchCount = 0; | ||
for (RowData accumulateData : currentWindowAccumulateDatas) { | ||
if (!hasRetractData(accumulateData)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for each input data, we have to iterate the retract state. I guess the performance should be very poor. Could we improve this?
} | ||
} | ||
|
||
private void emitWindowResult(W window) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method names emitWindowResult and emitResult are similar, however, the functionalities are very different.
What about rename emitWindowResult to something else, such as processWindow or triggerWindow.
for (int i = 0; i < namedProperties.length; i++) { | ||
switch (namedProperties[i]) { | ||
case 0: | ||
windowProperty.setField(i, TimestampData.fromEpochMillis(((TimeWindow) currentWindow).getStart())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it's always TimeWindow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because CountWindow won't set the start property or the end property, we can make sure it is a TimeWindow.
} | ||
|
||
@Override | ||
public void clearWindowState(W window) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will this method be called?
} | ||
|
||
@Override | ||
public void clearTrigger(W window) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
self.assert_equals(actual, ["1,2.5", "1,5.5", "2,2.0", "3,2.5"]) | ||
os.remove(source_path) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also add test case for Tumble window?
@dianfu Thanks a lot for the review. I have addressed the comments at the latest commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HuangXingBo Thanks for the update. Just two minor comments.
internalTimerService.deleteEventTimeTimer(window, time); | ||
} | ||
|
||
public void clear() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void clear() throws Exception { | |
@Override | |
public void clear() throws Exception { |
@@ -259,6 +261,246 @@ def test_over_window_aggregate_function(self): | |||
"3,2.0,3,2.0,1.0,1.0,2.0,2.0,1.0,1.0"]) | |||
|
|||
|
|||
class StreamPandasUDAFITTests(PyFlinkBlinkStreamTableTestCase): | |||
def test_sliding_group_window_over_time(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you improve the test cases containing multiple keys?
@dianfu Thanks a lot for the review. I have addressed the comments at the latest commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What is the purpose of the change
This pull request will support Pandas Stream Group Window Aggregation
Brief change log
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation