Skip to content

Commit e9ceaa3

Browse files
committed
ESQL: Fix name test for TOP
Sometimes we rewrite `TOP` into `MIN` or `MAX`.
1 parent 1a1954f commit e9ceaa3

File tree

1 file changed

+13
-1
lines changed
  • x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate

1 file changed

+13
-1
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopTests.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,25 @@ private static TestCaseSupplier makeSupplier(
304304
.limit(limit)
305305
.toList();
306306

307+
String baseName;
308+
if (limit != 1) {
309+
baseName = "Top";
310+
} else {
311+
// If the limit is 1 we rewrite TOP into MIN or MAX and never run our lovely TOP code.
312+
if (order.equals("asc")) {
313+
baseName = "Min";
314+
} else {
315+
baseName = "Max";
316+
}
317+
}
318+
307319
return new TestCaseSupplier.TestCase(
308320
List.of(
309321
fieldTypedData,
310322
limitTypedData,
311323
new TestCaseSupplier.TypedData(new BytesRef(order), DataType.KEYWORD, order + " order").forceLiteral()
312324
),
313-
standardAggregatorName("Top", fieldTypedData.type()),
325+
standardAggregatorName(baseName, fieldTypedData.type()),
314326
fieldSupplier.type(),
315327
equalTo(expected.size() == 1 ? expected.get(0) : expected)
316328
);

0 commit comments

Comments
 (0)