Skip to content

Commit b2ac6b9

Browse files
committed
report all encountered inlinejoins
1 parent 78ddc3d commit b2ac6b9

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/capabilities/PostOptimizationPlanVerificationAware.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public interface PostOptimizationPlanVerificationAware {
3838
* public BiConsumer<LogicalPlan, Failures> postOptimizationPlanVerification() {
3939
* return (p, failures) -> {
4040
* if (p instanceof InlineJoin inlineJoin) {
41-
* inlineJoin.left().forEachUp(OrderBy.class, orderBy -> {
41+
* inlineJoin.forEachUp(OrderBy.class, orderBy -> {
4242
* failures.add(
4343
* fail(
4444
* inlineJoin,

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/OrderBy.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,19 @@ public void postAnalysisVerification(Failures failures) {
123123
public BiConsumer<LogicalPlan, Failures> postOptimizationPlanVerification() {
124124
return (p, failures) -> {
125125
if (p instanceof InlineJoin inlineJoin) {
126-
// walking up the UnaryPlans only, not to warn twice on consecutive INLINESTATS
127-
inlineJoin.left().forEachUp(UnaryPlan.class, unary -> {
128-
if (unary instanceof OrderBy orderBy) {
129-
failures.add(
126+
inlineJoin.left()
127+
.forEachUp(
128+
OrderBy.class,
129+
orderBy -> failures.add(
130130
fail(
131131
inlineJoin,
132132
"inlinestats [{}] cannot yet have an unbounded sort [{}] before it : either move the sort after it,"
133133
+ " or add a limit before the sort",
134134
inlineJoin.sourceText(),
135135
orderBy.sourceText()
136136
)
137-
);
138-
}
139-
});
137+
)
138+
);
140139
} else if (p instanceof OrderBy) {
141140
failures.add(fail(p, "Unbounded sort not supported yet [{}] please add a limit", p.sourceText()));
142141
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/OptimizerVerificationTests.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import static org.elasticsearch.xpack.esql.plugin.EsqlPlugin.INLINESTATS_FEATURE_FLAG;
3131
import static org.hamcrest.Matchers.containsString;
3232
import static org.hamcrest.Matchers.instanceOf;
33+
import static org.hamcrest.Matchers.is;
3334

3435
public class OptimizerVerificationTests extends AbstractLogicalPlanOptimizerTests {
3536

@@ -439,13 +440,11 @@ public void testDanglingOrderByInInlineStats() {
439440
| INLINESTATS s = sum(salary) BY first_name
440441
""", analyzer);
441442

442-
assertThat(
443-
err,
444-
containsString(
445-
"2:3: Unbounded sort not supported yet [SORT languages] please add a limit\n"
446-
+ "line 3:3: inlinestats [INLINESTATS count(*) BY languages] cannot yet have an unbounded sort [SORT languages] before"
447-
+ " it : either move the sort after it, or add a limit before the sort"
448-
)
449-
);
443+
assertThat(err, is("""
444+
2:3: Unbounded sort not supported yet [SORT languages] please add a limit
445+
line 3:3: inlinestats [INLINESTATS count(*) BY languages] cannot yet have an unbounded sort [SORT languages] before\
446+
it : either move the sort after it, or add a limit before the sort
447+
line 4:3: inlinestats [INLINESTATS s = sum(salary) BY first_name] cannot yet have an unbounded sort [SORT languages]\
448+
before it : either move the sort after it, or add a limit before the sort"""));
450449
}
451450
}

0 commit comments

Comments
 (0)