Skip to content

Commit bcf0892

Browse files
Test adding checks
1 parent 3a69d45 commit bcf0892

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/LocalLogicalPlanOptimizer.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
package org.elasticsearch.xpack.esql.optimizer;
99

10+
import org.elasticsearch.xpack.esql.VerificationException;
11+
import org.elasticsearch.xpack.esql.common.Failures;
1012
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PropagateEmptyRelation;
1113
import org.elasticsearch.xpack.esql.optimizer.rules.logical.ReplaceStatsFilteredAggWithEval;
1214
import org.elasticsearch.xpack.esql.optimizer.rules.logical.ReplaceStringCasingWithInsensitiveRegexMatch;
@@ -35,6 +37,8 @@
3537
*/
3638
public 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
}

0 commit comments

Comments
 (0)