@@ -69,6 +69,21 @@ public void testLookupJoinAcrossClusters() throws IOException {
6969 EsqlExecutionInfo executionInfo = resp .getExecutionInfo ();
7070 assertCCSExecutionInfoDetails (executionInfo );
7171 }
72+
73+ // populateLookupIndex(LOCAL_CLUSTER, "values_lookup2", 5);
74+ // populateLookupIndex(REMOTE_CLUSTER_1, "values_lookup2", 5);
75+ // FIXME: this currently does not work
76+ // try (
77+ // EsqlQueryResponse resp = runQuery(
78+ // "FROM logs-*,c*:logs-* | EVAL lookup_key = v | LOOKUP JOIN values_lookup ON lookup_key | LOOKUP JOIN values_lookup2 ON
79+ // lookup_tag",
80+ // randomBoolean()
81+ // )
82+ // ) {
83+ // List<List<Object>> values = getValuesList(resp);
84+ // assertThat(values, hasSize(20));
85+ //
86+ // }
7287 }
7388
7489 public void testLookupJoinMissingRemoteIndex () throws IOException {
@@ -98,31 +113,50 @@ public void testLookupJoinMissingRemoteIndex() throws IOException {
98113 assertThat (failure .reason (), containsString ("lookup index [values_lookup] is not available in remote cluster [cluster-a]" ));
99114 }
100115 // Without local
116+ // FIXME: this is inconsistent due to how field-caps works - if there's no index at all, it fails, but if there's one but not
117+ // another, it succeeds. Ideally, this would be empty result with remote1 skipped, but field-caps fails.
118+ var ex = expectThrows (
119+ VerificationException .class ,
120+ () -> runQuery ("FROM c*:logs-* | EVAL lookup_key = v | LOOKUP JOIN values_lookup ON lookup_key" , randomBoolean ())
121+ );
122+ assertThat (ex .getMessage (), containsString ("Unknown index [cluster-a:values_lookup]" ));
123+
124+ setSkipUnavailable (REMOTE_CLUSTER_1 , false );
125+ // then missing index is an error
126+ ex = expectThrows (
127+ VerificationException .class ,
128+ () -> runQuery ("FROM logs-*,c*:logs-* | EVAL lookup_key = v | LOOKUP JOIN values_lookup ON lookup_key" , randomBoolean ())
129+ );
130+ assertThat (ex .getMessage (), containsString ("lookup index [values_lookup] is not available in remote cluster [cluster-a]" ));
131+ }
132+
133+ public void testLookupJoinMissingRemoteIndexTwoRemotes () throws IOException {
134+ setupClusters (3 );
135+ populateLookupIndex (REMOTE_CLUSTER_2 , "values_lookup" , 10 );
136+
137+ setSkipUnavailable (REMOTE_CLUSTER_1 , true );
138+ setSkipUnavailable (REMOTE_CLUSTER_2 , false );
139+
140+ // FIXME: inconsistent with the previous test, remote1:values_lookup still missing, but now it succeeds with remote1 skipped
101141 try (
102142 EsqlQueryResponse resp = runQuery (
103- "FROM c *:logs-* | EVAL lookup_key = v | LOOKUP JOIN values_lookup ON lookup_key" ,
143+ "FROM *:logs-* | EVAL lookup_key = v | LOOKUP JOIN values_lookup ON lookup_key" ,
104144 randomBoolean ()
105145 )
106146 ) {
107147 List <List <Object >> values = getValuesList (resp );
108- assertThat (values , hasSize (0 ));
148+ assertThat (values , hasSize (10 ));
109149 EsqlExecutionInfo executionInfo = resp .getExecutionInfo ();
110- assertThat (executionInfo .getClusters ().size (), equalTo (1 ));
150+ assertThat (executionInfo .getClusters ().size (), equalTo (2 ));
111151
112- var remoteCluster = executionInfo .getCluster (REMOTE_CLUSTER_1 );
113- assertThat (remoteCluster .getStatus (), equalTo (EsqlExecutionInfo .Cluster .Status .SKIPPED ));
114- assertThat (remoteCluster .getFailures (), not (empty ()));
115- var failure = remoteCluster .getFailures ().get (0 );
152+ var remoteCluster1 = executionInfo .getCluster (REMOTE_CLUSTER_1 );
153+ assertThat (remoteCluster1 .getStatus (), equalTo (EsqlExecutionInfo .Cluster .Status .SKIPPED ));
154+ assertThat (remoteCluster1 .getFailures (), not (empty ()));
155+ var failure = remoteCluster1 .getFailures ().get (0 );
116156 assertThat (failure .reason (), containsString ("lookup index [values_lookup] is not available in remote cluster [cluster-a]" ));
157+ var remoteCluster2 = executionInfo .getCluster (REMOTE_CLUSTER_2 );
158+ assertThat (remoteCluster2 .getStatus (), equalTo (EsqlExecutionInfo .Cluster .Status .SUCCESSFUL ));
117159 }
118-
119- setSkipUnavailable (REMOTE_CLUSTER_1 , false );
120- // then missing index is an error
121- var ex = expectThrows (
122- VerificationException .class ,
123- () -> runQuery ("FROM logs-*,c*:logs-* | EVAL lookup_key = v | LOOKUP JOIN values_lookup ON lookup_key" , randomBoolean ())
124- );
125- assertThat (ex .getMessage (), containsString ("lookup index [values_lookup] is not available in remote cluster [cluster-a]" ));
126160 }
127161
128162 public void testLookupJoinMissingLocalIndex () throws IOException {
@@ -134,6 +168,26 @@ public void testLookupJoinMissingLocalIndex() throws IOException {
134168 () -> runQuery ("FROM logs-*,c*:logs-* | EVAL lookup_key = v | LOOKUP JOIN values_lookup ON lookup_key" , randomBoolean ())
135169 );
136170 assertThat (ex .getMessage (), containsString ("lookup index [values_lookup] is not available in local cluster" ));
171+
172+ // Without local in the query it's ok
173+ try (
174+ EsqlQueryResponse resp = runQuery (
175+ "FROM c*:logs-* | EVAL lookup_key = v | LOOKUP JOIN values_lookup ON lookup_key" ,
176+ randomBoolean ()
177+ )
178+ ) {
179+ List <List <Object >> values = getValuesList (resp );
180+ assertThat (values , hasSize (10 ));
181+ var columns = resp .columns ().stream ().map (ColumnInfoImpl ::name ).toList ();
182+ assertThat (columns , hasItems ("lookup_key" , "lookup_name" , "lookup_tag" , "v" , "tag" , "remote_tag" ));
183+ assertThat (columns , not (hasItems ("local_tag" )));
184+
185+ EsqlExecutionInfo executionInfo = resp .getExecutionInfo ();
186+ assertThat (executionInfo .getClusters ().size (), equalTo (1 ));
187+
188+ var remoteCluster = executionInfo .getCluster (REMOTE_CLUSTER_1 );
189+ assertThat (remoteCluster .getStatus (), equalTo (EsqlExecutionInfo .Cluster .Status .SUCCESSFUL ));
190+ }
137191 }
138192
139193 public void testLookupJoinMissingKey () throws IOException {
@@ -143,6 +197,7 @@ public void testLookupJoinMissingKey() throws IOException {
143197
144198 setSkipUnavailable (REMOTE_CLUSTER_1 , true );
145199 try (
200+ // Using local_tag as key which is not present in remote index
146201 EsqlQueryResponse resp = runQuery (
147202 "FROM logs-*,c*:logs-* | EVAL local_tag = to_string(v) | LOOKUP JOIN values_lookup ON local_tag" ,
148203 randomBoolean ()
@@ -153,12 +208,11 @@ public void testLookupJoinMissingKey() throws IOException {
153208 EsqlExecutionInfo executionInfo = resp .getExecutionInfo ();
154209 assertThat (executionInfo .getClusters ().size (), equalTo (2 ));
155210
211+ var localCluster = executionInfo .getCluster (LOCAL_CLUSTER );
212+ assertThat (localCluster .getStatus (), equalTo (EsqlExecutionInfo .Cluster .Status .SUCCESSFUL ));
156213 var remoteCluster = executionInfo .getCluster (REMOTE_CLUSTER_1 );
157214 // FIXME: verify whether we need to skip or succeed here
158- // assertThat(remoteCluster.getStatus(), equalTo(EsqlExecutionInfo.Cluster.Status.SKIPPED));
159- // assertThat(remoteCluster.getFailures(), not(empty()));
160- // var failure = remoteCluster.getFailures().get(0);
161- // assertThat(failure.reason(), containsString("lookup index [values_lookup] is not available in remote cluster [cluster-a]"));
215+ assertThat (remoteCluster .getStatus (), equalTo (EsqlExecutionInfo .Cluster .Status .SUCCESSFUL ));
162216 }
163217
164218 // TODO: verify whether this should be an error or not when the key field is missing
@@ -175,6 +229,24 @@ public void testLookupJoinMissingKey() throws IOException {
175229 assertThat (ex .getMessage (), containsString ("Unknown column [local_tag] in right side of join" ));
176230
177231 setSkipUnavailable (REMOTE_CLUSTER_1 , false );
232+ try (
233+ // Using local_tag as key which is not present in remote index
234+ EsqlQueryResponse resp = runQuery (
235+ "FROM logs-*,c*:logs-* | EVAL local_tag = to_string(v) | LOOKUP JOIN values_lookup ON local_tag" ,
236+ randomBoolean ()
237+ )
238+ ) {
239+ List <List <Object >> values = getValuesList (resp );
240+ assertThat (values , hasSize (20 ));
241+ EsqlExecutionInfo executionInfo = resp .getExecutionInfo ();
242+ assertThat (executionInfo .getClusters ().size (), equalTo (2 ));
243+
244+ var localCluster = executionInfo .getCluster (LOCAL_CLUSTER );
245+ assertThat (localCluster .getStatus (), equalTo (EsqlExecutionInfo .Cluster .Status .SUCCESSFUL ));
246+ var remoteCluster = executionInfo .getCluster (REMOTE_CLUSTER_1 );
247+ // FIXME: verify whether we need to succeed or fail here
248+ assertThat (remoteCluster .getStatus (), equalTo (EsqlExecutionInfo .Cluster .Status .SUCCESSFUL ));
249+ }
178250 }
179251
180252 public void testLookupJoinIndexMode () throws IOException {
0 commit comments