Skip to content
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 @@ -119,6 +119,7 @@
import com.facebook.presto.sql.planner.optimizations.PruneUnreferencedOutputs;
import com.facebook.presto.sql.planner.optimizations.PushdownSubfields;
import com.facebook.presto.sql.planner.optimizations.ReplicateSemiJoinInDelete;
import com.facebook.presto.sql.planner.optimizations.RowExpressionPredicatePushDown;
import com.facebook.presto.sql.planner.optimizations.SetFlatteningOptimizer;
import com.facebook.presto.sql.planner.optimizations.StatsRecordingPlanOptimizer;
import com.facebook.presto.sql.planner.optimizations.TransformQuantifiedComparisonApplyToLateralJoin;
Expand Down Expand Up @@ -256,6 +257,7 @@ public PlanOptimizers(
new SimplifyRowExpressions(metadata).rules());

PlanOptimizer predicatePushDown = new StatsRecordingPlanOptimizer(optimizerStats, new PredicatePushDown(metadata, sqlParser));
PlanOptimizer rowExpressionPredicatePushDown = new StatsRecordingPlanOptimizer(optimizerStats, new RowExpressionPredicatePushDown(metadata, sqlParser));

builder.add(
// Clean up all the sugar in expressions, e.g. AtTimeZone, must be run before all the other optimizers
Expand Down Expand Up @@ -472,17 +474,6 @@ public PlanOptimizers(
ImmutableSet.of(new PushTableWriteThroughUnion()))); // Must run before AddExchanges
builder.add(new StatsRecordingPlanOptimizer(optimizerStats, new AddExchanges(metadata, sqlParser)));
}
//noinspection UnusedAssignment
estimatedExchangesCostCalculator = null; // Prevent accidental use after AddExchanges

builder.add(
new IterativeOptimizer(
ruleStats,
statsCalculator,
costCalculator,
ImmutableSet.of(new RemoveEmptyDelete()))); // Run RemoveEmptyDelete after table scan is removed by PickTableLayout/AddExchanges

builder.add(predicatePushDown); // Run predicate push down one more time in case we can leverage new information from layouts' effective predicate

// TODO: move this before optimization if possible!!
// Replace all expressions with row expressions
Expand All @@ -493,6 +484,17 @@ public PlanOptimizers(
new TranslateExpressions(metadata, sqlParser).rules()));
// After this point, all planNodes should not contain OriginalExpression

//noinspection UnusedAssignment
estimatedExchangesCostCalculator = null; // Prevent accidental use after AddExchanges

builder.add(
new IterativeOptimizer(
ruleStats,
statsCalculator,
costCalculator,
ImmutableSet.of(new RemoveEmptyDelete()))); // Run RemoveEmptyDelete after table scan is removed by PickTableLayout/AddExchanges

builder.add(rowExpressionPredicatePushDown); // Run predicate push down one more time in case we can leverage new information from layouts' effective predicate
builder.add(simplifyRowExpressionOptimizer); // Should be always run after PredicatePushDown
builder.add(projectionPushDown);
builder.add(inlineProjections);
Expand Down
Loading