Skip to content

Commit 5e43ea5

Browse files
authored
ESQL: mark LOOKUP JOIN as ExecutesOn.Any by default (#133064)
1 parent 55d3afe commit 5e43ea5

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

docs/changelog/133064.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 133064
2+
summary: Mark LOOKUP JOIN as `ExecutesOn.Any` by default
3+
area: ES|QL
4+
type: bug
5+
issues: []

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public boolean isRemote() {
318318

319319
@Override
320320
public ExecuteLocation executesOn() {
321-
return isRemote ? ExecuteLocation.REMOTE : ExecuteLocation.COORDINATOR;
321+
return isRemote ? ExecuteLocation.REMOTE : ExecuteLocation.ANY;
322322
}
323323

324324
private void checkRemoteJoin(Failures failures) {

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

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,40 @@ public void testRemoteEnrichAfterCoordinatorOnlyPlans() {
9595

9696
String err;
9797

98+
// Remote enrich is ok after limit
9899
plan("""
99100
FROM test
101+
| LIMIT 10
100102
| EVAL language_code = languages
101103
| ENRICH _remote:languages ON language_code
102104
| STATS count(*) BY language_name
103105
""", analyzer);
104106

107+
// Remote enrich is ok after topn
108+
plan("""
109+
FROM test
110+
| EVAL language_code = languages
111+
| SORT languages
112+
| ENRICH _remote:languages ON language_code
113+
""", analyzer);
114+
plan("""
115+
FROM test
116+
| EVAL language_code = languages
117+
| SORT languages
118+
| LIMIT 2
119+
| ENRICH _remote:languages ON language_code
120+
""", analyzer);
121+
122+
// Remote enrich is ok before pipeline breakers
105123
plan("""
106124
FROM test
125+
| EVAL language_code = languages
126+
| ENRICH _remote:languages ON language_code
107127
| LIMIT 10
128+
""", analyzer);
129+
130+
plan("""
131+
FROM test
108132
| EVAL language_code = languages
109133
| ENRICH _remote:languages ON language_code
110134
| STATS count(*) BY language_name
@@ -118,6 +142,13 @@ public void testRemoteEnrichAfterCoordinatorOnlyPlans() {
118142
| LIMIT 10
119143
""", analyzer);
120144

145+
plan("""
146+
FROM test
147+
| EVAL language_code = languages
148+
| ENRICH _remote:languages ON language_code
149+
| SORT language_name
150+
""", analyzer);
151+
121152
err = error("""
122153
FROM test
123154
| EVAL language_code = languages
@@ -230,6 +261,9 @@ public void testRemoteEnrichAfterCoordinatorOnlyPlans() {
230261
assertThat(err, containsString("4:3: ENRICH with remote policy can't be executed after [CHANGE_POINT salary ON languages]@2:3"));
231262
}
232263

264+
/**
265+
* The validation should not trigger for remote enrich after a lookup join. Lookup joins can be executed anywhere.
266+
*/
233267
public void testRemoteEnrichAfterLookupJoin() {
234268
EnrichResolution enrichResolution = new EnrichResolution();
235269
loadEnrichPolicyResolution(
@@ -257,32 +291,29 @@ public void testRemoteEnrichAfterLookupJoin() {
257291
| %s
258292
""", lookupCommand), analyzer);
259293

260-
String err = error(Strings.format("""
294+
plan(Strings.format("""
261295
FROM test
262296
| EVAL language_code = languages
263297
| %s
264298
| ENRICH _remote:languages ON language_code
265299
""", lookupCommand), analyzer);
266-
assertThat(err, containsString("4:3: ENRICH with remote policy can't be executed after [" + lookupCommand + "]@3:3"));
267300

268-
err = error(Strings.format("""
301+
plan(Strings.format("""
269302
FROM test
270303
| EVAL language_code = languages
271304
| %s
272305
| ENRICH _remote:languages ON language_code
273306
| %s
274307
""", lookupCommand, lookupCommand), analyzer);
275-
assertThat(err, containsString("4:3: ENRICH with remote policy can't be executed after [" + lookupCommand + "]@3:3"));
276308

277-
err = error(Strings.format("""
309+
plan(Strings.format("""
278310
FROM test
279311
| EVAL language_code = languages
280312
| %s
281313
| EVAL x = 1
282314
| MV_EXPAND language_code
283315
| ENRICH _remote:languages ON language_code
284316
""", lookupCommand), analyzer);
285-
assertThat(err, containsString("6:3: ENRICH with remote policy can't be executed after [" + lookupCommand + "]@3:3"));
286317
}
287318

288319
public void testRemoteLookupJoinWithPipelineBreaker() {

0 commit comments

Comments
 (0)