Skip to content

Commit 65791cc

Browse files
committed
Update LogicalPlanOptimizerTests
1 parent 3cabf9d commit 65791cc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,6 +2779,28 @@ private static List<String> orderNames(TopN topN) {
27792779
return topN.order().stream().map(o -> as(o.child(), NamedExpression.class).name()).toList();
27802780
}
27812781

2782+
2783+
/**
2784+
* Expects
2785+
* Eval[[2[INTEGER] AS x]]
2786+
* \_Limit[1000[INTEGER],false]
2787+
* \_Aggregate[[foo{r}#3],[foo{r}#3 AS x]]
2788+
* \_LocalRelation[[foo{r}#3],[IntVectorBlock[vector=ConstantIntVector[positions=1, value=1]]]]
2789+
*/
2790+
public void testEvalAfterGroupBy() {
2791+
var plan = optimizedPlan("""
2792+
ROW foo = 1
2793+
| STATS x = max(foo) by foo
2794+
| KEEP x
2795+
| EVAL x = 2
2796+
""");
2797+
var eval = as(plan, Eval.class);
2798+
var limit = as(eval.child(), Limit.class);
2799+
var aggregate = as(limit.child(), Aggregate.class);
2800+
var localRelation = as(aggregate.child(), LocalRelation.class);
2801+
assertThat(Expressions.names(eval.output()), contains("x"));
2802+
}
2803+
27822804
public void testCombineLimitWithOrderByThroughFilterAndEval() {
27832805
LogicalPlan plan = optimizedPlan("""
27842806
from test

0 commit comments

Comments
 (0)