Skip to content

Commit 218f5cd

Browse files
committed
Make inline sort alias name a prefix match
This reduces flakiness of this test.
1 parent 1b2ffa2 commit 218f5cd

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4769,12 +4769,23 @@ public void testPushTopNInlineDistanceToSource() {
47694769
var exchange = asRemoteExchange(topN.child());
47704770

47714771
project = as(exchange.child(), ProjectExec.class);
4772-
assertThat(names(project.projections()), contains("abbrev", "name", "location", "country", "city", "$$order_by$0$0"));
4772+
assertThat(
4773+
names(project.projections()),
4774+
contains(
4775+
equalTo("abbrev"),
4776+
equalTo("name"),
4777+
equalTo("location"),
4778+
equalTo("country"),
4779+
equalTo("city"),
4780+
startsWith("$$order_by$0$")
4781+
)
4782+
);
47734783
var extract = as(project.child(), FieldExtractExec.class);
47744784
assertThat(names(extract.attributesToExtract()), contains("abbrev", "name", "country", "city"));
47754785
var evalExec = as(extract.child(), EvalExec.class);
47764786
var alias = as(evalExec.fields().get(0), Alias.class);
4777-
assertThat(alias.name(), is("$$order_by$0$0"));
4787+
assertThat(alias.name(), startsWith("$$order_by$0$"));
4788+
var aliasName = alias.name();
47784789
var stDistance = as(alias.child(), StDistance.class);
47794790
assertThat(stDistance.left().toString(), startsWith("location"));
47804791
extract = as(evalExec.child(), FieldExtractExec.class);
@@ -4784,7 +4795,7 @@ public void testPushTopNInlineDistanceToSource() {
47844795
// Assert that the TopN(distance) is pushed down as geo-sort(location)
47854796
assertThat(source.limit(), is(topN.limit()));
47864797
Set<String> orderSet = orderAsSet(topN.order());
4787-
Set<String> sortsSet = sortsAsSet(source.sorts(), Map.of("location", "$$order_by$0$0"));
4798+
Set<String> sortsSet = sortsAsSet(source.sorts(), Map.of("location", aliasName));
47884799
assertThat(orderSet, is(sortsSet));
47894800

47904801
// Fine-grained checks on the pushed down sort

0 commit comments

Comments
 (0)