|
39 | 39 |
|
40 | 40 | import java.io.IOException; |
41 | 41 | import java.util.ArrayList; |
| 42 | +import java.util.HashSet; |
42 | 43 | import java.util.List; |
43 | 44 | import java.util.Locale; |
44 | 45 | import java.util.Map; |
@@ -309,36 +310,20 @@ private static void checkForPlansForbiddenBeforeRemoteEnrich(Enrich enrich, Fail |
309 | 310 | return; |
310 | 311 | } |
311 | 312 |
|
312 | | - // TODO: shouldn't we also include FORK? Everything downstream from FORK should be coordinator-only. |
313 | | - // https://github.com/elastic/elasticsearch/issues/131445 |
314 | | - boolean[] aggregate = { false }; |
315 | | - boolean[] coordinatorOnlyEnrich = { false }; |
316 | | - boolean[] lookupJoin = { false }; |
317 | | - boolean[] fork = { false }; |
| 313 | + Set<String> badCommands = new HashSet<>(); |
318 | 314 |
|
319 | 315 | enrich.forEachUp(LogicalPlan.class, u -> { |
320 | 316 | if (u instanceof Aggregate) { |
321 | | - aggregate[0] = true; |
| 317 | + badCommands.add("STATS"); |
322 | 318 | } else if (u instanceof Enrich upstreamEnrich && upstreamEnrich.mode() == Enrich.Mode.COORDINATOR) { |
323 | | - coordinatorOnlyEnrich[0] = true; |
| 319 | + badCommands.add("another ENRICH with coordinator policy"); |
324 | 320 | } else if (u instanceof LookupJoin) { |
325 | | - lookupJoin[0] = true; |
| 321 | + badCommands.add("LOOKUP JOIN"); |
326 | 322 | } else if (u instanceof Fork) { |
327 | | - fork[0] = true; |
| 323 | + badCommands.add("FORK"); |
328 | 324 | } |
329 | 325 | }); |
330 | 326 |
|
331 | | - if (aggregate[0]) { |
332 | | - failures.add(fail(enrich, "ENRICH with remote policy can't be executed after STATS")); |
333 | | - } |
334 | | - if (coordinatorOnlyEnrich[0]) { |
335 | | - failures.add(fail(enrich, "ENRICH with remote policy can't be executed after another ENRICH with coordinator policy")); |
336 | | - } |
337 | | - if (lookupJoin[0]) { |
338 | | - failures.add(fail(enrich, "ENRICH with remote policy can't be executed after LOOKUP JOIN")); |
339 | | - } |
340 | | - if (fork[0]) { |
341 | | - failures.add(fail(enrich, "ENRICH with remote policy can't be executed after FORK")); |
342 | | - } |
| 327 | + badCommands.forEach(c -> failures.add(fail(enrich, "ENRICH with remote policy can't be executed after " + c))); |
343 | 328 | } |
344 | 329 | } |
0 commit comments