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

Ensure to pushdown the aggregation for count(const) #4473

Merged
merged 1 commit into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ public PlanOptimizers(
new MergeLimitWithDistinct(),
new PruneCountAggregationOverScalar(metadata),
new PruneOrderByInAggregation(metadata),
new RewriteSpatialPartitioningAggregation(metadata)))
new RewriteSpatialPartitioningAggregation(metadata),
new SimplifyCountOverConstant(metadata)))
.build()),
new IterativeOptimizer(
ruleStats,
Expand Down Expand Up @@ -552,11 +553,6 @@ public PlanOptimizers(
new UnaliasSymbolReferences(metadata), // Run again because predicate pushdown and projection pushdown might add more projections
columnPruningOptimizer, // Make sure to run this before index join. Filtered projections may not have all the columns.
new IndexJoinOptimizer(metadata), // Run this after projections and filters have been fully simplified and pushed down
new IterativeOptimizer(
ruleStats,
statsCalculator,
estimatedExchangesCostCalculator,
ImmutableSet.of(new SimplifyCountOverConstant(metadata))),
new LimitPushDown(), // Run LimitPushDown before WindowFilterPushDown
new WindowFilterPushDown(metadata), // This must run after PredicatePushDown and LimitPushDown so that it squashes any successive filter nodes and limits
new IterativeOptimizer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public void testAggregationPushdown()

assertAggregationPushedDown("SELECT count(*) FROM nation");
assertAggregationPushedDown("SELECT count(nationkey) FROM nation");
assertAggregationPushedDown("SELECT count(1) FROM nation");
assertAggregationPushedDown("SELECT count() FROM nation");
assertAggregationPushedDown("SELECT regionkey, min(nationkey) FROM nation GROUP BY regionkey");
assertAggregationPushedDown("SELECT regionkey, max(nationkey) FROM nation GROUP BY regionkey");
assertAggregationPushedDown("SELECT regionkey, sum(nationkey) FROM nation GROUP BY regionkey");
Expand Down