Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

HuangXingBo
Copy link
Contributor

What is the purpose of the change

This pull request will support Pandas Stream Group Window Aggregation

Brief change log

  • Add StreamArrowPythonGroupWindowAggregateFunctionOperator
  • Add Physical Rule and RelNode

Verifying this change

This change added tests and can be verified as follows:

  • Add UT PythonGroupWindowAggregateTest
  • Add IT StreamPandasUDAFITTests

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (no)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (no)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (not applicable)

@flinkbot
Copy link
Collaborator

flinkbot commented Sep 25, 2020

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit cceb5e9 (Fri Feb 19 07:28:25 UTC 2021)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

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 commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Sep 25, 2020

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run travis re-run the last Travis build
  • @flinkbot run azure re-run the last Azure build

@@ -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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Iterable<RowData> currentWindowAccumulateDatas = windowAccumulateData.get();
Iterable<RowData> currentWindowAccumulateData = windowAccumulateData.get();

if (currentWindowAccumulateDatas != null) {
currentBatchCount = 0;
for (RowData accumulateData : currentWindowAccumulateDatas) {
if (!hasRetractData(accumulateData)) {
Copy link
Contributor

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 {
Copy link
Contributor

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()));
Copy link
Contributor

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?

Copy link
Contributor Author

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) {
Copy link
Contributor

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 {
Copy link
Contributor

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)


Copy link
Contributor

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?

@HuangXingBo
Copy link
Contributor Author

@dianfu Thanks a lot for the review. I have addressed the comments at the latest commit.

Copy link
Contributor

@dianfu dianfu left a 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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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):
Copy link
Contributor

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?

@HuangXingBo
Copy link
Contributor Author

@dianfu Thanks a lot for the review. I have addressed the comments at the latest commit.

Copy link
Contributor

@dianfu dianfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dianfu dianfu closed this in 0bd4e46 Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants