Skip to content

Add additional runs of columnPruningRules and WindowFilterPushDown #25176

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -2,14 +2,14 @@ local exchange (GATHER, SINGLE, [])
remote exchange (GATHER, SINGLE, [])
join (INNER, PARTITIONED):
join (INNER, PARTITIONED):
final aggregation over (i_item_id)
final aggregation over (i_item_id_79)
local exchange (GATHER, SINGLE, [])
remote exchange (REPARTITION, HASH, [i_item_id])
partial aggregation over (i_item_id)
remote exchange (REPARTITION, HASH, [i_item_id_79])
partial aggregation over (i_item_id_79)
semijoin (REPLICATED):
join (INNER, REPLICATED):
join (INNER, REPLICATED):
scan store_sales
scan catalog_sales
local exchange (GATHER, SINGLE, [])
remote exchange (REPLICATE, BROADCAST, [])
scan date_dim
Expand All @@ -25,14 +25,14 @@ local exchange (GATHER, SINGLE, [])
local exchange (GATHER, SINGLE, [])
remote exchange (GATHER, SINGLE, [])
scan date_dim
final aggregation over (i_item_id_79)
final aggregation over (i_item_id_210)
local exchange (GATHER, SINGLE, [])
remote exchange (REPARTITION, HASH, [i_item_id_79])
partial aggregation over (i_item_id_79)
remote exchange (REPARTITION, HASH, [i_item_id_210])
partial aggregation over (i_item_id_210)
semijoin (REPLICATED):
join (INNER, REPLICATED):
join (INNER, REPLICATED):
scan catalog_sales
scan web_sales
local exchange (GATHER, SINGLE, [])
remote exchange (REPLICATE, BROADCAST, [])
scan date_dim
Expand All @@ -48,14 +48,14 @@ local exchange (GATHER, SINGLE, [])
local exchange (GATHER, SINGLE, [])
remote exchange (GATHER, SINGLE, [])
scan date_dim
final aggregation over (i_item_id_210)
final aggregation over (i_item_id)
local exchange (GATHER, SINGLE, [])
remote exchange (REPARTITION, HASH, [i_item_id_210])
partial aggregation over (i_item_id_210)
remote exchange (REPARTITION, HASH, [i_item_id])
partial aggregation over (i_item_id)
semijoin (REPLICATED):
join (INNER, REPLICATED):
join (INNER, REPLICATED):
scan web_sales
scan store_sales
local exchange (GATHER, SINGLE, [])
remote exchange (REPLICATE, BROADCAST, [])
scan date_dim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,14 @@ public PlanOptimizers(
builder.add(new SimplifyPlanWithEmptyInput(),
new PruneUnreferencedOutputs());

// Run columnPruningRules one more time to optimize the ProjectNode generated in SimplifyPlanWithEmptyInput.
builder.add(new IterativeOptimizer(
metadata,
ruleStats,
statsCalculator,
estimatedExchangesCostCalculator,
columnPruningRules));

builder.add(new IterativeOptimizer(
metadata,
ruleStats,
Expand Down Expand Up @@ -886,6 +894,7 @@ public PlanOptimizers(
// Run RemoveEmptyDelete and EliminateEmptyJoins after table scan is removed by PickTableLayout/AddExchanges
ImmutableSet.of(new RemoveEmptyDelete())));
builder.add(predicatePushDown); // Run predicate push down one more time in case we can leverage new information from layouts' effective predicate
builder.add(new WindowFilterPushDown(metadata));
builder.add(new RemoveUnsupportedDynamicFilters(metadata.getFunctionAndTypeManager()));
builder.add(simplifyRowExpressionOptimizer); // Should be always run after PredicatePushDown
builder.add(projectionPushDown);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import static com.facebook.presto.common.type.BigintType.BIGINT;
import static com.facebook.presto.expressions.LogicalRowExpressions.TRUE_CONSTANT;
import static com.facebook.presto.sql.planner.plan.ChildReplacer.replaceChildren;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Verify.verify;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.lang.Math.toIntExact;
Expand Down Expand Up @@ -116,7 +115,6 @@ public boolean isPlanChanged()
@Override
public PlanNode visitWindow(WindowNode node, RewriteContext<Void> context)
{
checkState(node.getWindowFunctions().size() == 1, "WindowFilterPushdown requires that WindowNodes contain exactly one window function");
PlanNode rewrittenSource = context.rewrite(node.getSource());

if (canReplaceWithRowNumber(node, metadata.getFunctionAndTypeManager())) {
Expand Down
Loading