Move InlineSqlFunctions to beginning of plan optimizers
When we inline SQL functions, SQL functions are equivalent to syntax sugar.
Thus moving the optimization to the begining of plan optimizer rules together
with all other expression desugaring rules.
@@ -281,6 +281,7 @@ public class PlanOptimizers
statsCalculator,
estimatedExchangesCostCalculator,
ImmutableSet.<Rule<?>>builder()
+ .addAll(new InlineSqlFunctions(metadata, sqlParser).rules())
.addAll(new DesugarLambdaExpression().rules())
.addAll(new DesugarAtTimeZone(metadata, sqlParser).rules())
.addAll(new DesugarCurrentUser().rules())
@@ -347,11 +348,6 @@ public class PlanOptimizers
new LimitPushDown(), // Run the LimitPushDown after flattening set operators to make it easier to do the set flattening
new PruneUnreferencedOutputs(),
inlineProjections,
- new IterativeOptimizer(
- ruleStats,
- statsCalculator,
- estimatedExchangesCostCalculator,
- new InlineSqlFunctions(metadata, sqlParser).rules()),
new IterativeOptimizer(
ruleStats,
statsCalculator,
