Skip to content

Commit 2332a4b

Browse files
committed
Revert change to PruneEmptyPlans.java
1 parent 5e45b6c commit 2332a4b

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PruneEmptyPlans.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,13 @@
99

1010
import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan;
1111
import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan;
12-
import org.elasticsearch.xpack.esql.plan.logical.join.InlineJoin;
13-
import org.elasticsearch.xpack.esql.plan.logical.join.StubRelation;
1412
import org.elasticsearch.xpack.esql.plan.logical.local.EmptyLocalSupplier;
1513
import org.elasticsearch.xpack.esql.plan.logical.local.LocalRelation;
1614

1715
public final class PruneEmptyPlans extends OptimizerRules.OptimizerRule<UnaryPlan> {
1816

1917
public static LogicalPlan skipPlan(UnaryPlan plan) {
20-
// this basically is a decision to create a different shortcut for an empty plan for the right hand side of an InlineJoin
21-
// where the StubRelation is the EsRelation/LocalRelation equivalent
22-
return hasStubRelation(plan)
23-
? new StubRelation(plan.source(), plan.output())
24-
: new LocalRelation(plan.source(), plan.output(), EmptyLocalSupplier.EMPTY);
25-
}
26-
27-
private static boolean hasStubRelation(LogicalPlan plan) {
28-
for (var child : plan.children()) {
29-
if (child instanceof StubRelation) {
30-
return true;
31-
} else if (child instanceof InlineJoin) {
32-
// we don't want to find the StubRelation of a different InlineJoin
33-
return false;
34-
} else {
35-
return hasStubRelation(child);
36-
}
37-
}
38-
return false;
18+
return new LocalRelation(plan.source(), plan.output(), EmptyLocalSupplier.EMPTY);
3919
}
4020

4121
@Override

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/ReplaceStatsFilteredAggWithEval.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ protected LogicalPlan rule(LogicalPlan plan) {
105105
// project the correct output (the one of the former inlinejoin) and remove the InlineJoin altogether,
106106
// replacing it with its right-hand side followed by its left-hand side
107107
plan = new Project(newIJ.source(), newIJ.right(), newIJ.output());
108-
} else {
108+
} else { // this is a standalone Aggregate
109109
plan = localRelation(aggregate.source(), newEvals);
110110
}
111111
} else {
112-
if (ij.get() != null) {
112+
if (ij.get() != null) { // this is an Aggregate part of right-hand side of an InlineJoin
113113
// only update the Aggregate and add an Eval for the removed aggregations
114114
plan = ij.get().transformUp(Aggregate.class, agg -> {
115115
// if the aggregate is not the one we are looking for, return it unchanged
@@ -121,7 +121,7 @@ protected LogicalPlan rule(LogicalPlan plan) {
121121
newPlan = new Project(aggregate.source(), newPlan, newProjections);
122122
return newPlan;
123123
});
124-
} else {
124+
} else { // this is a standalone Aggregate
125125
plan = aggregate.with(aggregate.child(), aggregate.groupings(), newAggs);
126126
plan = new Eval(aggregate.source(), plan, newEvals);
127127
plan = new Project(aggregate.source(), plan, newProjections);

0 commit comments

Comments
 (0)