diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClusterLookupJoinIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClusterLookupJoinIT.java index fc6207a6e6872..1930d68ed790e 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClusterLookupJoinIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClusterLookupJoinIT.java @@ -284,6 +284,20 @@ public void testLookupJoinMissingLocalIndex() throws IOException { } } + public void testLookupJoinMissingLocalIndexAfterPipelineBreaker() throws IOException { + setupClusters(2); + populateLookupIndex(REMOTE_CLUSTER_1, "values_lookup", 10); + + expectThrows( + VerificationException.class, + containsString("LOOKUP JOIN with remote indices can't be executed after [STATS lookup_key = max(lookup_key)]"), + () -> runQuery( + "FROM c*:logs-* | EVAL lookup_key = v | STATS lookup_key = max(lookup_key) | LOOKUP JOIN values_lookup ON lookup_key", + randomBoolean() + ) + ); + } + public void testLookupJoinMissingKey() throws IOException { setupClusters(2); populateLookupIndex(LOCAL_CLUSTER, "values_lookup", 10);