Skip to content

Commit 602bf1a

Browse files
authored
[8.x] Update grammar to rely on indexPattern instead of identifier in join target (#120784)
* Update grammar to rely on indexPattern instead of identifier in join target (#120494) This replaces identifier with indexPattern in joinTarget grammar. This change is needed to make index selection consistent between FROM and [LOOKUP] JOIN commands: * Both should use the same quotes " (currently join relies on `) * Both should allow specifying indices with - without having to quote them (not possible with join at the moment) * Both should conform to allowed index names (there are number of differences today, for example it is possible to specify test? or +test in join even though it is not a valid index name.) (cherry picked from commit 9ffe3c8)
1 parent c1e5cff commit 602bf1a

File tree

25 files changed

+1228
-1011
lines changed

25 files changed

+1228
-1011
lines changed

docs/changelog/120494.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 120494
2+
summary: Update grammar to rely on `indexPattern` instead of identifier in join target
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlSecurityIT.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -538,12 +538,12 @@ record Listen(long timestamp, String songId, double duration) {
538538
public void testLookupJoinIndexAllowed() throws Exception {
539539
assumeTrue(
540540
"Requires LOOKUP JOIN capability",
541-
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V11.capabilityName()))
541+
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
542542
);
543543

544544
Response resp = runESQLCommand(
545545
"metadata1_read2",
546-
"ROW x = 40.0 | EVAL value = x | LOOKUP JOIN `lookup-user2` ON value | KEEP x, org"
546+
"ROW x = 40.0 | EVAL value = x | LOOKUP JOIN lookup-user2 ON value | KEEP x, org"
547547
);
548548
assertOK(resp);
549549
Map<String, Object> respMap = entityAsMap(resp);
@@ -554,7 +554,7 @@ public void testLookupJoinIndexAllowed() throws Exception {
554554
assertThat(respMap.get("values"), equalTo(List.of(List.of(40.0, "sales"))));
555555

556556
// Alias, should find the index and the row
557-
resp = runESQLCommand("alias_user1", "ROW x = 31.0 | EVAL value = x | LOOKUP JOIN `lookup-first-alias` ON value | KEEP x, org");
557+
resp = runESQLCommand("alias_user1", "ROW x = 31.0 | EVAL value = x | LOOKUP JOIN lookup-first-alias ON value | KEEP x, org");
558558
assertOK(resp);
559559
respMap = entityAsMap(resp);
560560
assertThat(
@@ -564,7 +564,7 @@ public void testLookupJoinIndexAllowed() throws Exception {
564564
assertThat(respMap.get("values"), equalTo(List.of(List.of(31.0, "sales"))));
565565

566566
// Alias, for a row that's filtered out
567-
resp = runESQLCommand("alias_user1", "ROW x = 123.0 | EVAL value = x | LOOKUP JOIN `lookup-first-alias` ON value | KEEP x, org");
567+
resp = runESQLCommand("alias_user1", "ROW x = 123.0 | EVAL value = x | LOOKUP JOIN lookup-first-alias ON value | KEEP x, org");
568568
assertOK(resp);
569569
respMap = entityAsMap(resp);
570570
assertThat(
@@ -577,12 +577,12 @@ public void testLookupJoinIndexAllowed() throws Exception {
577577
public void testLookupJoinIndexForbidden() throws Exception {
578578
assumeTrue(
579579
"Requires LOOKUP JOIN capability",
580-
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V11.capabilityName()))
580+
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.JOIN_LOOKUP_V12.capabilityName()))
581581
);
582582

583583
var resp = expectThrows(
584584
ResponseException.class,
585-
() -> runESQLCommand("metadata1_read2", "FROM lookup-user2 | EVAL value = 10.0 | LOOKUP JOIN `lookup-user1` ON value | KEEP x")
585+
() -> runESQLCommand("metadata1_read2", "FROM lookup-user2 | EVAL value = 10.0 | LOOKUP JOIN lookup-user1 ON value | KEEP x")
586586
);
587587
assertThat(resp.getMessage(), containsString("Unknown index [lookup-user1]"));
588588
assertThat(resp.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
@@ -591,22 +591,22 @@ public void testLookupJoinIndexForbidden() throws Exception {
591591
ResponseException.class,
592592
() -> runESQLCommand(
593593
"metadata1_read2",
594-
"FROM lookup-user2 | EVAL value = 10.0 | LOOKUP JOIN `lookup-first-alias` ON value | KEEP x"
594+
"FROM lookup-user2 | EVAL value = 10.0 | LOOKUP JOIN lookup-first-alias ON value | KEEP x"
595595
)
596596
);
597597
assertThat(resp.getMessage(), containsString("Unknown index [lookup-first-alias]"));
598598
assertThat(resp.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
599599

600600
resp = expectThrows(
601601
ResponseException.class,
602-
() -> runESQLCommand("metadata1_read2", "ROW x = 10.0 | EVAL value = x | LOOKUP JOIN `lookup-user1` ON value | KEEP x")
602+
() -> runESQLCommand("metadata1_read2", "ROW x = 10.0 | EVAL value = x | LOOKUP JOIN lookup-user1 ON value | KEEP x")
603603
);
604604
assertThat(resp.getMessage(), containsString("Unknown index [lookup-user1]"));
605605
assertThat(resp.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
606606

607607
resp = expectThrows(
608608
ResponseException.class,
609-
() -> runESQLCommand("alias_user1", "ROW x = 10.0 | EVAL value = x | LOOKUP JOIN `lookup-user1` ON value | KEEP x")
609+
() -> runESQLCommand("alias_user1", "ROW x = 10.0 | EVAL value = x | LOOKUP JOIN lookup-user1 ON value | KEEP x")
610610
);
611611
assertThat(resp.getMessage(), containsString("Unknown index [lookup-user1]"));
612612
assertThat(resp.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));

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_V11;
24+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V12;
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_V11.capabilityName()));
99+
return hasCapabilities(List.of(JOIN_LOOKUP_V12.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: 2 additions & 2 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_V11;
51+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V12;
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_V11.capabilityName()));
127+
assumeFalse("LOOKUP JOIN not yet supported in CCS", testCase.requiredCapabilities.contains(JOIN_LOOKUP_V12.capabilityName()));
128128
}
129129

130130
private TestFeatureService remoteFeaturesService() throws IOException {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public void testIndicesDontExist() throws IOException {
211211
assertThat(e.getMessage(), containsString("index_not_found_exception"));
212212
assertThat(e.getMessage(), anyOf(containsString("no such index [foo]"), containsString("no such index [remote_cluster:foo]")));
213213

214-
if (EsqlCapabilities.Cap.JOIN_LOOKUP_V11.isEnabled()) {
214+
if (EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled()) {
215215
e = expectThrows(
216216
ResponseException.class,
217217
() -> runEsql(timestampFilter("gte", "2020-01-01").query(from("test1") + " | LOOKUP JOIN foo ON id1"))

0 commit comments

Comments
 (0)