Move TranslateExpressions below AddExchange
@@ -474,15 +474,6 @@ public class 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
// TODO: move this before optimization if possible!!
// Replace all expressions with row expressions
@@ -493,6 +484,16 @@ public class 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);
