-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-20895] [flink-table-planner] support local aggregate push down in table planner #17344
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
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 479edc3 (Thu Sep 23 15:29:59 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:
|
...a/org/apache/flink/table/planner/plan/rules/physical/batch/PushLocalAggIntoScanRuleBase.java
Outdated
Show resolved
Hide resolved
...k-table-api-java/src/main/java/org/apache/flink/table/api/config/OptimizerConfigOptions.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/flink/table/planner/plan/abilities/source/AggregatePushDownSpec.java
Outdated
Show resolved
Hide resolved
...k-table-api-java/src/main/java/org/apache/flink/table/api/config/OptimizerConfigOptions.java
Outdated
Show resolved
Hide resolved
...a/org/apache/flink/table/planner/plan/rules/physical/batch/PushLocalAggIntoScanRuleBase.java
Outdated
Show resolved
Hide resolved
70104a7
to
4ad2900
Compare
@wuchong @godfreyhe Please take a look, thanks a lot. |
@iyupeng sorry for the late response, I start to review it now |
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.
Thanks for the contribution @iyupeng , I left some comment
...a/org/apache/flink/table/planner/plan/rules/physical/batch/PushLocalAggIntoScanRuleBase.java
Outdated
Show resolved
Hide resolved
...a/org/apache/flink/table/planner/plan/rules/physical/batch/PushLocalAggIntoScanRuleBase.java
Outdated
Show resolved
Hide resolved
...a/org/apache/flink/table/planner/plan/rules/physical/batch/PushLocalHashAggIntoScanRule.java
Outdated
Show resolved
Hide resolved
...e/flink/table/planner/plan/rules/physical/batch/PushLocalSortAggWithoutSortIntoScanRule.java
Outdated
Show resolved
Hide resolved
...e/flink/table/planner/plan/rules/physical/batch/PushLocalSortAggWithoutSortIntoScanRule.java
Outdated
Show resolved
Hide resolved
...e-planner/src/test/java/org/apache/flink/table/planner/factories/TestValuesTableFactory.java
Show resolved
Hide resolved
...e-planner/src/test/java/org/apache/flink/table/planner/factories/TestValuesTableFactory.java
Outdated
Show resolved
Hide resolved
...e/flink/table/planner/plan/rules/physical/batch/PushLocalAggIntoTableSourceScanRuleTest.java
Outdated
Show resolved
Hide resolved
...e/flink/table/planner/plan/rules/physical/batch/PushLocalAggIntoTableSourceScanRuleTest.java
Outdated
Show resolved
Hide resolved
...e/flink/table/planner/plan/rules/physical/batch/PushLocalAggIntoTableSourceScanRuleTest.java
Show resolved
Hide resolved
@godfreyhe Thanks for your comments. I plan to push new commits in a few days. |
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.
Thanks for the quick update @iyupeng, I left some comments about your changes
...rc/main/java/org/apache/flink/table/planner/plan/abilities/source/AggregatePushDownSpec.java
Outdated
Show resolved
Hide resolved
.../java/org/apache/flink/table/planner/runtime/batch/sql/agg/LocalAggregatePushDownITCase.java
Outdated
Show resolved
Hide resolved
.../java/org/apache/flink/table/planner/runtime/batch/sql/agg/LocalAggregatePushDownITCase.java
Outdated
Show resolved
Hide resolved
...a/org/apache/flink/table/planner/plan/rules/physical/batch/PushLocalAggIntoScanRuleBase.java
Outdated
Show resolved
Hide resolved
...a/org/apache/flink/table/planner/plan/rules/physical/batch/PushLocalAggIntoScanRuleBase.java
Outdated
Show resolved
Hide resolved
...ache/flink/table/planner/plan/rules/physical/batch/PushLocalSortAggWithCalcIntoScanRule.java
Outdated
Show resolved
Hide resolved
...ink/table/planner/plan/rules/physical/batch/PushLocalSortAggWithSortAndCalcIntoScanRule.java
Outdated
Show resolved
Hide resolved
...e-planner/src/test/java/org/apache/flink/table/planner/factories/TestValuesTableFactory.java
Outdated
Show resolved
Hide resolved
...e/flink/table/planner/plan/rules/physical/batch/PushLocalAggIntoTableSourceScanRuleTest.java
Outdated
Show resolved
Hide resolved
.../java/org/apache/flink/table/planner/runtime/batch/sql/agg/LocalAggregatePushDownITCase.java
Show resolved
Hide resolved
// Disable push down aggregates to avoid conflicts with existing test cases that verify plans. | ||
tableEnv.getConfig | ||
.getConfiguration | ||
.setBoolean( | ||
OptimizerConfigOptions.TABLE_OPTIMIZER_SOURCE_AGGREGATE_PUSHDOWN_ENABLED, false) |
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.
Currently, this pr do not change all tests except you added, so remove it ?
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.
Hello @godfreyhe, thanks for the comments.
2 existing test cases with local aggregate
and 'connector' = 'values'
can be affected if we enable aggregate push down
:
-
RankTest.scala#L172,
testCreateViewWithRowNumber
-
TableSourceTest.scala#L118,
testProjectWithoutInputRef
We need to change the plans of these 2 test cases in .xml
files if we remove above configuration.
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.
pushed a new commit 2ee07dc to solve this.
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 overall except one minor comment
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.
Thanks for the quick update, LGTM
* <p>Regardless if this interface is implemented or not, a final aggregation is always applied in a | ||
* subsequent operation after the source. | ||
* | ||
* <p>Note: currently, the {@link SupportsAggregatePushDown} is not supported by planner. |
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.
@iyupeng are we sure that the JavaDocs don't need more updates for this PR?
For example, is this description still correct?
* <p>Note: The local aggregate push down strategy is all or nothing, it can only be pushed down if
* all aggregate functions are supported.
Also maybe we should mention the config option that was added in this PR.
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.
Hi @twalthr, the strategy is still all or nothing
here. applyAggregates
returns a bool value, meaning whether all local aggregates are accepted by underlying data source or not at all.
The docs could be improved, like mentioning the new option, etc.
I could push a hotfix for docs.
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.
That would be great. The more information in the interface description, the better for all implementers.
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.
…le planner Co-authored-by: Sebastian Liu <liuyang0704@gmail.com> This closes apache#17344
What is the purpose of the change
This pull request follows #14894 which has been inactive for months.
This pull request addresses review comments in the existing pull request and is based on the existing one.
All the code changes are targeted to make it possible to push down local aggregations from computing layer to storage layer for better computing & I/O performance.
Brief change log
table.optimizer.source.aggregate-pushdown-enabled
to control the aggregation push down.PushLocalAggIntoScanRuleBase
for supporting both with and without sort operator.PushLocalSortAggIntoScanRule
for sort aggregation case.PushLocalSortAggWithSortIntoScanRule
for sort aggregation with sort case.PushLocalSortAggWithSortAndCalcIntoScanRule
for sort aggregation with sort & calc case.PushLocalHashAggIntoScanRule
for hash aggregation case.PushLocalHashAggWithCalcIntoScanRule
for hash aggregation with calc case.AggregatePushDownSpec
to serialize/deserialize aggregations.SupportsAggregatePushDown
interface forTestValuesScanTableSource
.Verifying this change
This change added tests and can be verified as follows:
PushLocalAggIntoTableSourceScanRuleTest
for plan verificationsLocalAggregatePushDownITCase
for end-to-end functional testDoes this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation