Skip to content

Commit b081c1a

Browse files
committed
Additional yaml test for missing join key on right side (#127906)
There are some analyser tests for this, but I thought it useful to also have a yaml test for more coverage, since there was temporarily an issue #120189 with this, later fixed in #120617.
1 parent 01fe5e8 commit b081c1a

File tree

1 file changed

+116
-2
lines changed

1 file changed

+116
-2
lines changed

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

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
setup:
33
- requires:
4-
test_runner_features: [capabilities, contains]
4+
test_runner_features: [capabilities, contains, allowed_warnings]
55
capabilities:
66
- method: POST
77
path: /_query
88
parameters: []
9-
capabilities: [join_lookup_v12]
9+
capabilities: [join_lookup_v12, join_lookup_skip_mv_warnings]
1010
reason: "uses LOOKUP JOIN"
1111
- do:
1212
indices.create:
@@ -18,6 +18,16 @@ setup:
1818
type: long
1919
color:
2020
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
2131
- do:
2232
indices.create:
2333
index: test-lookup-1
@@ -44,6 +54,32 @@ setup:
4454
type: long
4555
color:
4656
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
4783
- do:
4884
indices.update_aliases:
4985
body:
@@ -75,6 +111,37 @@ setup:
75111
- { "key": 1, "color": "cyan" }
76112
- { "index": { } }
77113
- { "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" }
78145

79146
---
80147
basic:
@@ -200,3 +267,50 @@ pattern-single:
200267

201268
- match: { error.type: "parsing_exception" }
202269
- contains: { error.reason: "line 1:36: invalid index pattern [test-lookup-1*], * is not allowed in LOOKUP JOIN" }
270+
271+
---
272+
mv-on-lookup:
273+
- do:
274+
esql.query:
275+
body:
276+
query: 'FROM test | SORT key | LOOKUP JOIN test-lookup-mv ON key'
277+
allowed_warnings:
278+
- "No limit defined, adding default limit of [1000]"
279+
- "Line 1:24: evaluation of [LOOKUP JOIN test-lookup-mv ON key] failed, treating result as null. Only first 20 failures recorded."
280+
- "Line 1:24: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value"
281+
282+
- match: {columns.0.name: "key"}
283+
- match: {columns.0.type: "long"}
284+
- match: {columns.1.name: "color"}
285+
- match: {columns.1.type: "keyword"}
286+
- match: {values.0: [1, "cyan"]}
287+
- match: {values.1: [2, "yellow"]}
288+
289+
---
290+
mv-on-query:
291+
- do:
292+
esql.query:
293+
body:
294+
query: 'FROM test-mv | SORT key | LOOKUP JOIN test-lookup-1 ON key | LIMIT 4'
295+
allowed_warnings:
296+
- "Line 1:27: evaluation of [LOOKUP JOIN test-lookup-1 ON key] failed, treating result as null. Only first 20 failures recorded."
297+
- "Line 1:27: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value"
298+
299+
- match: {columns.0.name: "key"}
300+
- match: {columns.0.type: "long"}
301+
- match: {columns.1.name: "color"}
302+
- match: {columns.1.type: "keyword"}
303+
- match: {values.0: [[0, 1, 2], null]}
304+
- match: {values.1: [1, "cyan"]}
305+
- match: {values.2: [2, "yellow"]}
306+
307+
---
308+
lookup-no-key:
309+
- do:
310+
esql.query:
311+
body:
312+
query: 'FROM test | LOOKUP JOIN test-lookup-no-key ON key | KEEP key, color'
313+
catch: "bad_request"
314+
315+
- match: { error.type: "verification_exception" }
316+
- contains: { error.reason: "Unknown column [key] in right side of join" }

0 commit comments

Comments
 (0)