Skip to content

Commit f00d907

Browse files
ES|QL: Split JOIN yaml tests so that non-alias queries run also on bwc (elastic#128902)
* ES|QL: Split JOIN yaml tests so that non-alias queries run also on bwc (elastic#128884) * Fix test
1 parent 264c415 commit f00d907

File tree

4 files changed

+214
-86
lines changed

4 files changed

+214
-86
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ public enum Cap {
904904
/**
905905
* Enable support for index aliases in lookup joins
906906
*/
907-
ENABLE_LOOKUP_JOIN_ON_ALIASES(JOIN_LOOKUP_V12.isEnabled()),
907+
ENABLE_LOOKUP_JOIN_ON_ALIASES,
908908

909909
/**
910910
* Allow lookup join on mixed numeric fields, among byte, short, int, long, half_float, scaled_float, float and double.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/LookupFromIndexService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public void writeTo(StreamOutput out) throws IOException {
190190
if (out.getTransportVersion().onOrAfter(TransportVersions.JOIN_ON_ALIASES_8_19)) {
191191
out.writeString(indexPattern);
192192
} else if (indexPattern.equals(shardId.getIndexName()) == false) {
193-
throw new EsqlIllegalArgumentException("Aliases and index patterns are not allowed for LOOKUP JOIN []", indexPattern);
193+
throw new EsqlIllegalArgumentException("Aliases and index patterns are not allowed for LOOKUP JOIN [{}]", indexPattern);
194194
}
195195

196196
out.writeString(inputDataType.typeName());

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/190_lookup_join.yml

Lines changed: 1 addition & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ setup:
66
- method: POST
77
path: /_query
88
parameters: []
9-
capabilities: [join_lookup_v12, enable_lookup_join_on_aliases]
9+
capabilities: [join_lookup_v12]
1010
reason: "uses LOOKUP JOIN"
1111
- do:
1212
indices.create:
@@ -44,19 +44,6 @@ setup:
4444
type: long
4545
color:
4646
type: keyword
47-
- do:
48-
indices.update_aliases:
49-
body:
50-
actions:
51-
- add:
52-
index: test-lookup-1
53-
alias: test-lookup-alias
54-
- add:
55-
index: test-lookup-*
56-
alias: test-lookup-alias-pattern-multiple
57-
- add:
58-
index: test-lookup-1*
59-
alias: test-lookup-alias-pattern-single
6047
- do:
6148
bulk:
6249
index: "test"
@@ -101,76 +88,6 @@ non-lookup index:
10188
- match: { error.type: "verification_exception" }
10289
- contains: { error.reason: "Found 1 problem\nline 1:45: invalid [test] resolution in lookup mode to an index in [standard] mode" }
10390

104-
---
105-
106-
"Alias as lookup index":
107-
- skip:
108-
awaits_fix: "LOOKUP JOIN does not support index aliases for now"
109-
- do:
110-
esql.query:
111-
body:
112-
query: 'FROM test | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3'
113-
114-
- match: {columns.0.name: "key"}
115-
- match: {columns.0.type: "long"}
116-
- match: {columns.1.name: "color"}
117-
- match: {columns.1.type: "keyword"}
118-
- match: {values.0: [1, "cyan"]}
119-
- match: {values.1: [2, "yellow"]}
120-
121-
---
122-
alias-repeated-alias:
123-
- do:
124-
esql.query:
125-
body:
126-
query: 'FROM test-lookup-alias | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3'
127-
128-
- match: {columns.0.name: "key"}
129-
- match: {columns.0.type: "long"}
130-
- match: {columns.1.name: "color"}
131-
- match: {columns.1.type: "keyword"}
132-
- match: {values.0: [1, "cyan"]}
133-
- match: {values.1: [2, "yellow"]}
134-
135-
---
136-
alias-repeated-index:
137-
- do:
138-
esql.query:
139-
body:
140-
query: 'FROM test-lookup-1 | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3'
141-
142-
- match: {columns.0.name: "key"}
143-
- match: {columns.0.type: "long"}
144-
- match: {columns.1.name: "color"}
145-
- match: {columns.1.type: "keyword"}
146-
- match: {values.0: [1, "cyan"]}
147-
- match: {values.1: [2, "yellow"]}
148-
149-
---
150-
alias-pattern-multiple:
151-
- do:
152-
esql.query:
153-
body:
154-
query: 'FROM test-lookup-1 | LOOKUP JOIN test-lookup-alias-pattern-multiple ON key'
155-
catch: "bad_request"
156-
157-
- match: { error.type: "verification_exception" }
158-
- contains: { error.reason: "Found 1 problem\nline 1:34: invalid [test-lookup-alias-pattern-multiple] resolution in lookup mode to [2] indices" }
159-
160-
---
161-
alias-pattern-single:
162-
- do:
163-
esql.query:
164-
body:
165-
query: 'FROM test | SORT key | LOOKUP JOIN test-lookup-alias-pattern-single ON key | LIMIT 3'
166-
167-
- match: {columns.0.name: "key"}
168-
- match: {columns.0.type: "long"}
169-
- match: {columns.1.name: "color"}
170-
- match: {columns.1.type: "keyword"}
171-
- match: {values.0: [1, "cyan"]}
172-
- match: {values.1: [2, "yellow"]}
173-
17491
---
17592
pattern-multiple:
17693
- do:
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
---
2+
setup:
3+
- requires:
4+
test_runner_features: [capabilities, contains, allowed_warnings]
5+
capabilities:
6+
- method: POST
7+
path: /_query
8+
parameters: []
9+
capabilities: [enable_lookup_join_on_aliases]
10+
reason: "uses LOOKUP JOIN on aliases"
11+
- do:
12+
indices.create:
13+
index: test
14+
body:
15+
mappings:
16+
properties:
17+
key:
18+
type: long
19+
color:
20+
type: keyword
21+
- do:
22+
indices.create:
23+
index: test-mv
24+
body:
25+
mappings:
26+
properties:
27+
key:
28+
type: long
29+
color:
30+
type: keyword
31+
- do:
32+
indices.create:
33+
index: test-lookup-1
34+
body:
35+
settings:
36+
index:
37+
mode: lookup
38+
mappings:
39+
properties:
40+
key:
41+
type: long
42+
color:
43+
type: keyword
44+
- do:
45+
indices.create:
46+
index: test-lookup-2
47+
body:
48+
settings:
49+
index:
50+
mode: lookup
51+
mappings:
52+
properties:
53+
key:
54+
type: long
55+
color:
56+
type: keyword
57+
- do:
58+
indices.create:
59+
index: test-lookup-mv
60+
body:
61+
settings:
62+
index:
63+
mode: lookup
64+
mappings:
65+
properties:
66+
key:
67+
type: long
68+
color:
69+
type: keyword
70+
- do:
71+
indices.create:
72+
index: test-lookup-no-key
73+
body:
74+
settings:
75+
index:
76+
mode: lookup
77+
mappings:
78+
properties:
79+
no-key:
80+
type: long
81+
color:
82+
type: keyword
83+
- do:
84+
indices.update_aliases:
85+
body:
86+
actions:
87+
- add:
88+
index: test-lookup-1
89+
alias: test-lookup-alias
90+
- add:
91+
index: test-lookup-*
92+
alias: test-lookup-alias-pattern-multiple
93+
- add:
94+
index: test-lookup-1*
95+
alias: test-lookup-alias-pattern-single
96+
- do:
97+
bulk:
98+
index: "test"
99+
refresh: true
100+
body:
101+
- { "index": { } }
102+
- { "key": 1, "color": "red" }
103+
- { "index": { } }
104+
- { "key": 2, "color": "blue" }
105+
- do:
106+
bulk:
107+
index: "test-lookup-1"
108+
refresh: true
109+
body:
110+
- { "index": { } }
111+
- { "key": 1, "color": "cyan" }
112+
- { "index": { } }
113+
- { "key": 2, "color": "yellow" }
114+
- do:
115+
bulk:
116+
index: "test-mv"
117+
refresh: true
118+
body:
119+
- { "index": { } }
120+
- { "key": 1, "color": "red" }
121+
- { "index": { } }
122+
- { "key": 2, "color": "blue" }
123+
- { "index": { } }
124+
- { "key": [0, 1, 2], "color": null }
125+
- do:
126+
bulk:
127+
index: "test-lookup-mv"
128+
refresh: true
129+
body:
130+
- { "index": { } }
131+
- { "key": 1, "color": "cyan" }
132+
- { "index": { } }
133+
- { "key": 2, "color": "yellow" }
134+
- { "index": { } }
135+
- { "key": [0, 1, 2], "color": "green" }
136+
- do:
137+
bulk:
138+
index: "test-lookup-no-key"
139+
refresh: true
140+
body:
141+
- { "index": { } }
142+
- { "no-key": 1, "color": "cyan" }
143+
- { "index": { } }
144+
- { "no-key": 2, "color": "yellow" }
145+
146+
---
147+
alias-as-lookup-index:
148+
- do:
149+
esql.query:
150+
body:
151+
query: 'FROM test | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3'
152+
153+
- match: {columns.0.name: "key"}
154+
- match: {columns.0.type: "long"}
155+
- match: {columns.1.name: "color"}
156+
- match: {columns.1.type: "keyword"}
157+
- match: {values.0: [1, "cyan"]}
158+
- match: {values.1: [2, "yellow"]}
159+
160+
---
161+
alias-repeated-alias:
162+
- do:
163+
esql.query:
164+
body:
165+
query: 'FROM test-lookup-alias | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3'
166+
167+
- match: {columns.0.name: "key"}
168+
- match: {columns.0.type: "long"}
169+
- match: {columns.1.name: "color"}
170+
- match: {columns.1.type: "keyword"}
171+
- match: {values.0: [1, "cyan"]}
172+
- match: {values.1: [2, "yellow"]}
173+
174+
---
175+
alias-repeated-index:
176+
- do:
177+
esql.query:
178+
body:
179+
query: 'FROM test-lookup-1 | SORT key | LOOKUP JOIN test-lookup-alias ON key | LIMIT 3'
180+
181+
- match: {columns.0.name: "key"}
182+
- match: {columns.0.type: "long"}
183+
- match: {columns.1.name: "color"}
184+
- match: {columns.1.type: "keyword"}
185+
- match: {values.0: [1, "cyan"]}
186+
- match: {values.1: [2, "yellow"]}
187+
188+
---
189+
alias-pattern-multiple:
190+
- do:
191+
esql.query:
192+
body:
193+
query: 'FROM test-lookup-1 | LOOKUP JOIN test-lookup-alias-pattern-multiple ON key'
194+
catch: "bad_request"
195+
196+
- match: { error.type: "verification_exception" }
197+
- contains: { error.reason: "Found 1 problem\nline 1:34: invalid [test-lookup-alias-pattern-multiple] resolution in lookup mode to [4] indices" }
198+
199+
---
200+
alias-pattern-single:
201+
- do:
202+
esql.query:
203+
body:
204+
query: 'FROM test | SORT key | LOOKUP JOIN test-lookup-alias-pattern-single ON key | LIMIT 3'
205+
206+
- match: {columns.0.name: "key"}
207+
- match: {columns.0.type: "long"}
208+
- match: {columns.1.name: "color"}
209+
- match: {columns.1.type: "keyword"}
210+
- match: {values.0: [1, "cyan"]}
211+
- match: {values.1: [2, "yellow"]}

0 commit comments

Comments
 (0)