Skip to content

Commit

Permalink
Use PushProjectionThrough{Union,Exchange} optimizers
Browse files Browse the repository at this point in the history
  • Loading branch information
losipiuk authored and martint committed May 17, 2017
1 parent c659747 commit 648528b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import com.facebook.presto.sql.planner.iterative.rule.PushLimitThroughMarkDistinct;
import com.facebook.presto.sql.planner.iterative.rule.PushLimitThroughProject;
import com.facebook.presto.sql.planner.iterative.rule.PushLimitThroughSemiJoin;
import com.facebook.presto.sql.planner.iterative.rule.PushProjectionThroughExchange;
import com.facebook.presto.sql.planner.iterative.rule.PushProjectionThroughUnion;
import com.facebook.presto.sql.planner.iterative.rule.PushTopNThroughUnion;
import com.facebook.presto.sql.planner.iterative.rule.RemoveEmptyDelete;
import com.facebook.presto.sql.planner.iterative.rule.RemoveFullSample;
Expand Down Expand Up @@ -126,6 +128,13 @@ public PlanOptimizers(Metadata metadata, SqlParser sqlParser, FeaturesConfig fea
new InlineProjections(),
new RemoveRedundantIdentityProjections()));

IterativeOptimizer projectionPushDown = new IterativeOptimizer(
stats,
ImmutableList.of(new ProjectionPushDown()),
ImmutableSet.of(
new PushProjectionThroughUnion(),
new PushProjectionThroughExchange()));

builder.add(
new DesugaringOptimizer(metadata, sqlParser), // Clean up all the sugar in expressions, e.g. AtTimeZone, must be run before all the other optimizers
new CanonicalizeExpressions(),
Expand Down Expand Up @@ -182,7 +191,7 @@ public PlanOptimizers(Metadata metadata, SqlParser sqlParser, FeaturesConfig fea
),
inlineProjections,
new SimplifyExpressions(metadata, sqlParser), // Re-run the SimplifyExpressions to simplify any recomposed expressions from other optimizations
new ProjectionPushDown(),
projectionPushDown,
new UnaliasSymbolReferences(), // Run again because predicate pushdown and projection pushdown might add more projections
new PruneUnreferencedOutputs(), // 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
Expand All @@ -206,7 +215,7 @@ public PlanOptimizers(Metadata metadata, SqlParser sqlParser, FeaturesConfig fea
new MetadataQueryOptimizer(metadata),
new EliminateCrossJoins(), // This can pull up Filter and Project nodes from between Joins, so we need to push them down again
new PredicatePushDown(metadata, sqlParser),
new ProjectionPushDown());
projectionPushDown);

if (featuresConfig.isOptimizeSingleDistinct()) {
builder.add(
Expand Down Expand Up @@ -238,7 +247,7 @@ public PlanOptimizers(Metadata metadata, SqlParser sqlParser, FeaturesConfig fea
));

builder.add(new PredicatePushDown(metadata, sqlParser)); // Run predicate push down one more time in case we can leverage new information from layouts' effective predicate
builder.add(new ProjectionPushDown());
builder.add(projectionPushDown);
builder.add(inlineProjections);
builder.add(new UnaliasSymbolReferences()); // Run unalias after merging projections to simplify projections more efficiently
builder.add(new PruneUnreferencedOutputs());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import static com.facebook.presto.sql.planner.plan.ChildReplacer.replaceChildren;
import static java.util.Objects.requireNonNull;

@Deprecated
public class ProjectionPushDown
implements PlanOptimizer
{
Expand Down

0 comments on commit 648528b

Please sign in to comment.