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-12098] [table-planner-blink] Add support for generating optimized logical plan for simple group aggregate on stream #8110

Merged
merged 11 commits into from
Apr 11, 2019

Conversation

godfreyhe
Copy link
Contributor

@godfreyhe godfreyhe commented Apr 3, 2019

What is the purpose of the change

Add support for generating optimized logical plan for simple group aggregate on stream

Brief change log

  • add StreamExecGroupAggregateRule to convert logical aggregate to StreamExecGroupAggregate
  • add TwoStageOptimizedAggregateRule to write StreamExecGroupAggregate to two-stage aggregates
  • add StreamExecRetractionRules to handle retraction message

Verifying this change

This change added tests and can be verified as follows:

  • Added AggregateTest for StreamExecGroupAggregateRule
  • Added TwoStageAggregateTest for TwoStageOptimizedAggregateRule
  • Added RetractionRulesTest for retraction rules

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, 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 documented)

@flinkbot
Copy link
Collaborator

flinkbot commented Apr 3, 2019

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.

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

import java.sql.{Date, Time, Timestamp}

/** The initial accumulator for Max with retraction aggregate function */
class MaxWithRetractAccumulator[T] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this Java?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, should implements MinWithRetractAggFunctionTest as java in this PR?

import java.sql.{Date, Time, Timestamp}

/** The initial accumulator for Min with retraction aggregate function */
class MinWithRetractAccumulator[T] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this Java?

groupSize: Int,
needRetraction: Boolean,
aggs: Seq[AggregateCall]): Array[Boolean] = {

Copy link
Contributor

Choose a reason for hiding this comment

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

delete blank line

inputRowType: RelDataType,
groupSet: Array[Int],
typeFactory: FlinkTypeFactory): RelDataType = {

Copy link
Contributor

Choose a reason for hiding this comment

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

delete blank line

* Derives accumulators names from aggregate
*/
def inferAggAccumulatorNames(aggInfoList: AggregateInfoList): Array[String] = {

Copy link
Contributor

Choose a reason for hiding this comment

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

delete blank line

/** The initial accumulator for Max with retraction aggregate function. */
public static class MaxWithRetractAccumulator<T> {
public T max;
public Long distinctCount;
Copy link
Contributor

Choose a reason for hiding this comment

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

just use mapSize? the name is a little bit confusing with distinct agg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

@Override
public MaxWithRetractAccumulator<T> createAccumulator() {
MaxWithRetractAccumulator<T> acc = new MaxWithRetractAccumulator<>();
acc.max = getInitValue(); // max
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just use NULL to represent init value for all sub-classes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I does not change any logic when porting to java.
for java, using NULL as init value is ok.

hasMax = true;
}
}
if (!hasMax) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would this happen?

Copy link
Contributor Author

@godfreyhe godfreyhe Apr 8, 2019

Choose a reason for hiding this comment

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

The behavior of deleting expired data in the state backend is uncertain.
so mapSize data may exist while map data may have been deleted when both of them are expired.

I have added some comments.

@godfreyhe godfreyhe force-pushed the FLINK-12098 branch 2 times, most recently from f980267 to bf9ee8c Compare April 9, 2019 01:40
@KurtYoung
Copy link
Contributor

LGTM, +1 to merge

@KurtYoung KurtYoung merged commit 517a04f into apache:master Apr 11, 2019
@godfreyhe godfreyhe deleted the FLINK-12098 branch April 11, 2019 07:22
HuangZhenQiu pushed a commit to HuangZhenQiu/flink that referenced this pull request Apr 22, 2019
…ed logical plan for simple group aggregate on stream (apache#8110)
sunhaibotb pushed a commit to sunhaibotb/flink that referenced this pull request May 8, 2019
…ed logical plan for simple group aggregate on stream (apache#8110)
tianchen92 pushed a commit to tianchen92/flink that referenced this pull request May 13, 2019
…ed logical plan for simple group aggregate on stream (apache#8110)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants