File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 77
88package org .elasticsearch .xpack .esql .optimizer ;
99
10+ import org .elasticsearch .xpack .esql .VerificationException ;
11+ import org .elasticsearch .xpack .esql .common .Failures ;
1012import org .elasticsearch .xpack .esql .optimizer .rules .logical .PropagateEmptyRelation ;
1113import org .elasticsearch .xpack .esql .optimizer .rules .logical .ReplaceStatsFilteredAggWithEval ;
1214import org .elasticsearch .xpack .esql .optimizer .rules .logical .ReplaceStringCasingWithInsensitiveRegexMatch ;
3537 */
3638public class LocalLogicalPlanOptimizer extends ParameterizedRuleExecutor <LogicalPlan , LocalLogicalOptimizerContext > {
3739
40+ private final LogicalVerifier verifier = LogicalVerifier .INSTANCE ;
41+
3842 private static final List <Batch <LogicalPlan >> RULES = arrayAsArrayList (
3943 new Batch <>(
4044 "Local rewrite" ,
@@ -81,6 +85,16 @@ private static Batch<LogicalPlan> localOperators() {
8185 }
8286
8387 public LogicalPlan localOptimize (LogicalPlan plan ) {
84- return execute (plan );
88+ Failures failures = verifier .verify (plan );
89+ if (failures .hasFailures ()) {
90+ throw new VerificationException ("Plan before optimize not valid: " + failures + " for plan: " + plan .nodeString ());
91+ }
92+ LogicalPlan optimized = execute (plan );
93+ failures = verifier .verify (optimized );
94+ if (failures .hasFailures ()) {
95+ throw new VerificationException ("Plan after optimize not valid: " + failures + " for plan: " + plan .nodeString ());
96+ }
97+ return optimized ;
8598 }
99+
86100}
You can’t perform that action at this time.
0 commit comments