Skip to content

Commit cfeeb1a

Browse files
authored
ESQL: Test LOOKUP JOIN with alias for index pattern (#120292)
1 parent 523e1d3 commit cfeeb1a

File tree

1 file changed

+52
-7
lines changed

1 file changed

+52
-7
lines changed

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

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,21 @@ setup:
2020
type: keyword
2121
- do:
2222
indices.create:
23-
index: test-lookup
23+
index: test-lookup-1
24+
body:
25+
settings:
26+
index:
27+
mode: lookup
28+
number_of_shards: 1
29+
mappings:
30+
properties:
31+
key:
32+
type: long
33+
color:
34+
type: keyword
35+
- do:
36+
indices.create:
37+
index: test-lookup-2
2438
body:
2539
settings:
2640
index:
@@ -36,8 +50,14 @@ setup:
3650
body:
3751
actions:
3852
- add:
39-
index: test-lookup
53+
index: test-lookup-1
4054
alias: test-lookup-alias
55+
- add:
56+
index: test-lookup-*
57+
alias: test-lookup-alias-pattern-multiple
58+
- add:
59+
index: test-lookup-1*
60+
alias: test-lookup-alias-pattern-single
4161
- do:
4262
bulk:
4363
index: "test"
@@ -49,7 +69,7 @@ setup:
4969
- { "key": 2, "color": "blue" }
5070
- do:
5171
bulk:
52-
index: "test-lookup"
72+
index: "test-lookup-1"
5373
refresh: true
5474
body:
5575
- { "index": { } }
@@ -62,7 +82,7 @@ basic:
6282
- do:
6383
esql.query:
6484
body:
65-
query: 'FROM test | SORT key | LOOKUP JOIN `test-lookup` ON key | LIMIT 3'
85+
query: 'FROM test | SORT key | LOOKUP JOIN `test-lookup-1` ON key | LIMIT 3'
6686

6787
- match: {columns.0.name: "key"}
6888
- match: {columns.0.type: "long"}
@@ -76,11 +96,11 @@ non-lookup index:
7696
- do:
7797
esql.query:
7898
body:
79-
query: 'FROM test-lookup | SORT key | LOOKUP JOIN `test` ON key | LIMIT 3'
99+
query: 'FROM test-lookup-1 | SORT key | LOOKUP JOIN `test` ON key | LIMIT 3'
80100
catch: "bad_request"
81101

82102
- match: { error.type: "verification_exception" }
83-
- contains: { error.reason: "Found 1 problem\nline 1:43: invalid [test] resolution in lookup mode to an index in [standard] mode" }
103+
- contains: { error.reason: "Found 1 problem\nline 1:45: invalid [test] resolution in lookup mode to an index in [standard] mode" }
84104

85105
---
86106
alias:
@@ -115,7 +135,32 @@ alias-repeated-index:
115135
- do:
116136
esql.query:
117137
body:
118-
query: 'FROM test-lookup | SORT key | LOOKUP JOIN `test-lookup-alias` ON key | LIMIT 3'
138+
query: 'FROM test-lookup-1 | SORT key | LOOKUP JOIN `test-lookup-alias` ON key | LIMIT 3'
139+
140+
- match: {columns.0.name: "key"}
141+
- match: {columns.0.type: "long"}
142+
- match: {columns.1.name: "color"}
143+
- match: {columns.1.type: "keyword"}
144+
- match: {values.0: [1, "cyan"]}
145+
- match: {values.1: [2, "yellow"]}
146+
147+
---
148+
alias-pattern-multiple:
149+
- do:
150+
esql.query:
151+
body:
152+
query: 'FROM test-lookup-1 | LOOKUP JOIN `test-lookup-alias-pattern-multiple` ON key'
153+
catch: "bad_request"
154+
155+
- match: { error.type: "verification_exception" }
156+
- contains: { error.reason: "Found 1 problem\nline 1:34: invalid [test-lookup-alias-pattern-multiple] resolution in lookup mode to [2] indices" }
157+
158+
---
159+
alias-pattern-single:
160+
- do:
161+
esql.query:
162+
body:
163+
query: 'FROM test | SORT key | LOOKUP JOIN `test-lookup-alias-pattern-single` ON key | LIMIT 3'
119164

120165
- match: {columns.0.name: "key"}
121166
- match: {columns.0.type: "long"}

0 commit comments

Comments
 (0)