Skip to content

Commit 9d40e10

Browse files
committed
Add tests
1 parent 66e7767 commit 9d40e10

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,74 @@ public void testRemoteLookupJoinWithPipelineBreaker() {
324324
// Since FORK, RERANK, COMPLETION and CHANGE_POINT are not supported on remote indices, we can't check them here against the remote
325325
// LOOKUP JOIN
326326
}
327+
328+
public void testRemoteEnrichAfterLookupJoinWithPipelineBreaker() {
329+
EnrichResolution enrichResolution = new EnrichResolution();
330+
loadEnrichPolicyResolution(
331+
enrichResolution,
332+
Enrich.Mode.REMOTE,
333+
MATCH_TYPE,
334+
"languages",
335+
"language_code",
336+
"languages_idx",
337+
"mapping-languages.json"
338+
);
339+
loadEnrichPolicyResolution(
340+
enrichResolution,
341+
Enrich.Mode.COORDINATOR,
342+
MATCH_TYPE,
343+
"languages_coord",
344+
"language_code",
345+
"languages_idx",
346+
"mapping-languages.json"
347+
);
348+
var analyzer = AnalyzerTestUtils.analyzer(
349+
loadMapping("mapping-default.json", "test"),
350+
defaultLookupResolution(),
351+
enrichResolution,
352+
TEST_VERIFIER
353+
);
354+
355+
String err = error("""
356+
FROM test
357+
| STATS c = COUNT(*) by languages
358+
| EVAL language_code = languages
359+
| LOOKUP JOIN languages_lookup ON language_code
360+
| ENRICH _remote:languages ON language_code
361+
""", analyzer);
362+
assertThat(
363+
err,
364+
containsString("4:3: LOOKUP JOIN with remote indices can't be executed after [STATS c = COUNT(*) by languages]@2:3")
365+
);
366+
367+
err = error("""
368+
FROM test
369+
| SORT emp_no
370+
| EVAL language_code = languages
371+
| LOOKUP JOIN languages_lookup ON language_code
372+
| ENRICH _remote:languages ON language_code
373+
""", analyzer);
374+
assertThat(err, containsString("4:3: LOOKUP JOIN with remote indices can't be executed after [SORT emp_no]@2:3"));
375+
376+
err = error("""
377+
FROM test
378+
| LIMIT 2
379+
| EVAL language_code = languages
380+
| LOOKUP JOIN languages_lookup ON language_code
381+
| ENRICH _remote:languages ON language_code
382+
""", analyzer);
383+
assertThat(err, containsString("4:3: LOOKUP JOIN with remote indices can't be executed after [LIMIT 2]@2:3"));
384+
385+
err = error("""
386+
FROM test
387+
| EVAL language_code = languages
388+
| ENRICH _coordinator:languages_coord
389+
| LOOKUP JOIN languages_lookup ON language_code
390+
| ENRICH _remote:languages ON language_code
391+
""", analyzer);
392+
assertThat(
393+
err,
394+
containsString("4:3: LOOKUP JOIN with remote indices can't be executed after [ENRICH _coordinator:languages_coord]@3:3")
395+
);
396+
}
327397
}

0 commit comments

Comments
 (0)