Skip to content

Commit 8e98868

Browse files
Support multi-index LOOKUP JOIN and various bug fixes (#118429)
While working on supporting multi-index LOOKUP JOIN; various bugs were fixed: * Previously we just used '*' for lookup-join indices, because the fieldnames were sometimes not being correctly determined. The problem was with KEEP referencing fields from the right that had previously been defined on the left as aliases, including using the ROW command. We normally don't want to ask for aliases, but if they could be shadowed by a lookup join, we need to keep them. * With both single and multi-index LOOKUP JOIN we need to mark each index as potentially wildcard fields, if the KEEP commands occur before the LOOKUP JOIN.
1 parent cf1f2cb commit 8e98868

File tree

16 files changed

+902
-265
lines changed

16 files changed

+902
-265
lines changed

x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/MixedClusterEsqlSpecIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.List;
2222

2323
import static org.elasticsearch.xpack.esql.CsvTestUtils.isEnabled;
24-
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V5;
24+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V6;
2525
import static org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase.Mode.ASYNC;
2626

2727
public class MixedClusterEsqlSpecIT extends EsqlSpecTestCase {
@@ -96,7 +96,7 @@ protected boolean supportsInferenceTestService() {
9696

9797
@Override
9898
protected boolean supportsIndexModeLookup() throws IOException {
99-
return hasCapabilities(List.of(JOIN_LOOKUP_V5.capabilityName()));
99+
return hasCapabilities(List.of(JOIN_LOOKUP_V6.capabilityName()));
100100
}
101101

102102
@Override

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import static org.elasticsearch.xpack.esql.EsqlTestUtils.classpathResources;
4949
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS;
5050
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS_V2;
51-
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V5;
51+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V6;
5252
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_PLANNING_V1;
5353
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.METADATA_FIELDS_REMOTE_TEST;
5454
import static org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase.Mode.SYNC;
@@ -124,7 +124,7 @@ protected void shouldSkipTest(String testName) throws IOException {
124124
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(INLINESTATS.capabilityName()));
125125
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(INLINESTATS_V2.capabilityName()));
126126
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(JOIN_PLANNING_V1.capabilityName()));
127-
assumeFalse("LOOKUP JOIN not yet supported in CCS", testCase.requiredCapabilities.contains(JOIN_LOOKUP_V5.capabilityName()));
127+
assumeFalse("LOOKUP JOIN not yet supported in CCS", testCase.requiredCapabilities.contains(JOIN_LOOKUP_V6.capabilityName()));
128128
}
129129

130130
private TestFeatureService remoteFeaturesService() throws IOException {
@@ -283,8 +283,8 @@ protected boolean supportsInferenceTestService() {
283283

284284
@Override
285285
protected boolean supportsIndexModeLookup() throws IOException {
286-
// CCS does not yet support JOIN_LOOKUP_V5 and clusters falsely report they have this capability
287-
// return hasCapabilities(List.of(JOIN_LOOKUP_V5.capabilityName()));
286+
// CCS does not yet support JOIN_LOOKUP_V6 and clusters falsely report they have this capability
287+
// return hasCapabilities(List.of(JOIN_LOOKUP_V6.capabilityName()));
288288
return false;
289289
}
290290
}

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RequestIndexFilteringTestCase.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.test.rest.ESRestTestCase;
1515
import org.elasticsearch.xcontent.XContentType;
1616
import org.elasticsearch.xpack.esql.AssertWarnings;
17+
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1718
import org.junit.After;
1819
import org.junit.Assert;
1920

@@ -219,6 +220,16 @@ public void testIndicesDontExist() throws IOException {
219220
assertEquals(404, e.getResponse().getStatusLine().getStatusCode());
220221
assertThat(e.getMessage(), containsString("index_not_found_exception"));
221222
assertThat(e.getMessage(), containsString("no such index [foo]"));
223+
224+
if (EsqlCapabilities.Cap.JOIN_LOOKUP_V6.isEnabled()) {
225+
e = expectThrows(
226+
ResponseException.class,
227+
() -> runEsql(timestampFilter("gte", "2020-01-01").query("FROM test1 | LOOKUP JOIN foo ON id1"))
228+
);
229+
assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
230+
assertThat(e.getMessage(), containsString("verification_exception"));
231+
assertThat(e.getMessage(), containsString("Unknown index [foo]"));
232+
}
222233
}
223234

224235
private static RestEsqlTestCase.RequestObjectBuilder timestampFilter(String op, String date) throws IOException {

0 commit comments

Comments
 (0)