Move TranslateExpressions below GatherAndMergeWindows
@@ -403,14 +403,7 @@ public class PlanOptimizers
// add UnaliasSymbolReferences when it's ported
.add(new RemoveRedundantIdentityProjections())
.addAll(GatherAndMergeWindows.rules())
- .build()),
- inlineProjections,
- new PruneUnreferencedOutputs(), // Make sure to run this at the end to help clean the plan for logging/execution and not remove info that other optimizers might need at an earlier point
- new IterativeOptimizer(
- ruleStats,
- statsCalculator,
- estimatedExchangesCostCalculator,
- ImmutableSet.of(new RemoveRedundantIdentityProjections())));
+ .build()));
// TODO: move this before optimization if possible!!
// Replace all expressions with row expressions
@@ -421,6 +414,15 @@ public class PlanOptimizers
new TranslateExpressions(metadata, sqlParser).rules()));
// After this point, all planNodes should not contain OriginalExpression
+ builder.add(
+ inlineProjections,
+ new PruneUnreferencedOutputs(), // Make sure to run this at the end to help clean the plan for logging/execution and not remove info that other optimizers might need at an earlier point
+ new IterativeOptimizer(
+ ruleStats,
+ statsCalculator,
+ estimatedExchangesCostCalculator,
+ ImmutableSet.of(new RemoveRedundantIdentityProjections())));
+
builder.add(new MetadataQueryOptimizer(metadata));
// This can pull up Filter and Project nodes from between Joins, so we need to push them down again
