Skip to content

Commit 4fc2df6

Browse files
committed
Add additional runs of columnPruningRules and WindowFilterPushDown
1 parent 5bbdf93 commit 4fc2df6

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

presto-benchto-benchmarks/src/test/resources/sql/presto/tpcds/q58.plan.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ local exchange (GATHER, SINGLE, [])
22
remote exchange (GATHER, SINGLE, [])
33
join (INNER, PARTITIONED):
44
join (INNER, PARTITIONED):
5-
final aggregation over (i_item_id)
5+
final aggregation over (i_item_id_79)
66
local exchange (GATHER, SINGLE, [])
7-
remote exchange (REPARTITION, HASH, [i_item_id])
8-
partial aggregation over (i_item_id)
7+
remote exchange (REPARTITION, HASH, [i_item_id_79])
8+
partial aggregation over (i_item_id_79)
99
semijoin (REPLICATED):
1010
join (INNER, REPLICATED):
1111
join (INNER, REPLICATED):
12-
scan store_sales
12+
scan catalog_sales
1313
local exchange (GATHER, SINGLE, [])
1414
remote exchange (REPLICATE, BROADCAST, [])
1515
scan date_dim
@@ -25,14 +25,14 @@ local exchange (GATHER, SINGLE, [])
2525
local exchange (GATHER, SINGLE, [])
2626
remote exchange (GATHER, SINGLE, [])
2727
scan date_dim
28-
final aggregation over (i_item_id_79)
28+
final aggregation over (i_item_id_210)
2929
local exchange (GATHER, SINGLE, [])
30-
remote exchange (REPARTITION, HASH, [i_item_id_79])
31-
partial aggregation over (i_item_id_79)
30+
remote exchange (REPARTITION, HASH, [i_item_id_210])
31+
partial aggregation over (i_item_id_210)
3232
semijoin (REPLICATED):
3333
join (INNER, REPLICATED):
3434
join (INNER, REPLICATED):
35-
scan catalog_sales
35+
scan web_sales
3636
local exchange (GATHER, SINGLE, [])
3737
remote exchange (REPLICATE, BROADCAST, [])
3838
scan date_dim
@@ -48,14 +48,14 @@ local exchange (GATHER, SINGLE, [])
4848
local exchange (GATHER, SINGLE, [])
4949
remote exchange (GATHER, SINGLE, [])
5050
scan date_dim
51-
final aggregation over (i_item_id_210)
51+
final aggregation over (i_item_id)
5252
local exchange (GATHER, SINGLE, [])
53-
remote exchange (REPARTITION, HASH, [i_item_id_210])
54-
partial aggregation over (i_item_id_210)
53+
remote exchange (REPARTITION, HASH, [i_item_id])
54+
partial aggregation over (i_item_id)
5555
semijoin (REPLICATED):
5656
join (INNER, REPLICATED):
5757
join (INNER, REPLICATED):
58-
scan web_sales
58+
scan store_sales
5959
local exchange (GATHER, SINGLE, [])
6060
remote exchange (REPLICATE, BROADCAST, [])
6161
scan date_dim

presto-main-base/src/main/java/com/facebook/presto/sql/planner/PlanOptimizers.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,14 @@ public PlanOptimizers(
733733
builder.add(new SimplifyPlanWithEmptyInput(),
734734
new PruneUnreferencedOutputs());
735735

736+
// Run columnPruningRules one more time to optimize the ProjectNode generated in SimplifyPlanWithEmptyInput.
737+
builder.add(new IterativeOptimizer(
738+
metadata,
739+
ruleStats,
740+
statsCalculator,
741+
estimatedExchangesCostCalculator,
742+
columnPruningRules));
743+
736744
builder.add(new IterativeOptimizer(
737745
metadata,
738746
ruleStats,
@@ -886,6 +894,7 @@ public PlanOptimizers(
886894
// Run RemoveEmptyDelete and EliminateEmptyJoins after table scan is removed by PickTableLayout/AddExchanges
887895
ImmutableSet.of(new RemoveEmptyDelete())));
888896
builder.add(predicatePushDown); // Run predicate push down one more time in case we can leverage new information from layouts' effective predicate
897+
builder.add(new WindowFilterPushDown(metadata));
889898
builder.add(new RemoveUnsupportedDynamicFilters(metadata.getFunctionAndTypeManager()));
890899
builder.add(simplifyRowExpressionOptimizer); // Should be always run after PredicatePushDown
891900
builder.add(projectionPushDown);

presto-main-base/src/main/java/com/facebook/presto/sql/planner/optimizations/WindowFilterPushDown.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import static com.facebook.presto.common.type.BigintType.BIGINT;
5252
import static com.facebook.presto.expressions.LogicalRowExpressions.TRUE_CONSTANT;
5353
import static com.facebook.presto.sql.planner.plan.ChildReplacer.replaceChildren;
54-
import static com.google.common.base.Preconditions.checkState;
5554
import static com.google.common.base.Verify.verify;
5655
import static com.google.common.collect.Iterables.getOnlyElement;
5756
import static java.lang.Math.toIntExact;
@@ -116,7 +115,6 @@ public boolean isPlanChanged()
116115
@Override
117116
public PlanNode visitWindow(WindowNode node, RewriteContext<Void> context)
118117
{
119-
checkState(node.getWindowFunctions().size() == 1, "WindowFilterPushdown requires that WindowNodes contain exactly one window function");
120118
PlanNode rewrittenSource = context.rewrite(node.getSource());
121119

122120
if (canReplaceWithRowNumber(node, metadata.getFunctionAndTypeManager())) {

0 commit comments

Comments
 (0)