Skip to content

Commit 8ac9dbe

Browse files
committed
Restrict remote LOOKUP JOIN after FORK
1 parent 8a7f522 commit 8ac9dbe

File tree

2 files changed

+14
-0
lines changed
  • x-pack/plugin/esql/src

2 files changed

+14
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ private static void checkForPlansForbiddenBeforeRemoteEnrich(Enrich enrich, Fail
314314
boolean[] aggregate = { false };
315315
boolean[] coordinatorOnlyEnrich = { false };
316316
boolean[] lookupJoin = { false };
317+
boolean[] fork = { false };
317318

318319
enrich.forEachUp(LogicalPlan.class, u -> {
319320
if (u instanceof Aggregate) {
@@ -322,6 +323,8 @@ private static void checkForPlansForbiddenBeforeRemoteEnrich(Enrich enrich, Fail
322323
coordinatorOnlyEnrich[0] = true;
323324
} else if (u instanceof LookupJoin) {
324325
lookupJoin[0] = true;
326+
} else if (u instanceof Fork) {
327+
fork[0] = true;
325328
}
326329
});
327330

@@ -334,5 +337,8 @@ private static void checkForPlansForbiddenBeforeRemoteEnrich(Enrich enrich, Fail
334337
if (lookupJoin[0]) {
335338
failures.add(fail(enrich, "ENRICH with remote policy can't be executed after LOOKUP JOIN"));
336339
}
340+
if (fork[0]) {
341+
failures.add(fail(enrich, "ENRICH with remote policy can't be executed after FORK"));
342+
}
337343
}
338344
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,14 @@ public void testRemoteEnrichAfterCoordinatorOnlyPlans() {
24572457
| ENRICH _remote:languages ON language_code
24582458
""", analyzer);
24592459
assertThat(err, containsString("7:3: ENRICH with remote policy can't be executed after another ENRICH with coordinator policy"));
2460+
2461+
err = error("""
2462+
FROM test
2463+
| FORK (WHERE languages == 1) (WHERE languages == 2)
2464+
| EVAL language_code = languages
2465+
| ENRICH _remote:languages ON language_code
2466+
""", analyzer);
2467+
assertThat(err, containsString("4:3: ENRICH with remote policy can't be executed after FORK"));
24602468
}
24612469

24622470
private void checkFullTextFunctionsInStats(String functionInvocation) {

0 commit comments

Comments
 (0)