Skip to content

Commit 5d381a3

Browse files
authored
ESQL: Add LOOKUP JOIN tests with null and mv join keys (#118761) (#118779)
Notable behavior: - `null` join keys never match anything, even a `null` from the left hand side. - If a lookup index document has multi-valued join keys, it will match with all left hand side rows that contain any of the multi-values. - If the left hand side has multi-values, it will match with any lookup index document whose join key contains any of the multi-values.
1 parent 3a5cf8d commit 5d381a3

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/resources/languages_non_unique_key.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ language_code:integer,language_name:keyword,country:keyword
88
2,German,
99
4,Quenya,
1010
5,,Atlantis
11+
[6,7],Mv-Lang,Mv-Land
12+
[7,8],Mv-Lang2,Mv-Land2
13+
,Null-Lang,Null-Land
14+
,Null-Lang2,Null-Land2

x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,73 @@ language_code:integer | language_name:keyword | country:keyword
178178
2 | [German, German, German] | [Austria, Germany, Switzerland]
179179
;
180180

181+
nullJoinKeyOnTheDataNode
182+
required_capability: join_lookup_v5
183+
184+
FROM employees
185+
| WHERE emp_no < 10004
186+
| EVAL language_code = emp_no % 10, language_code = CASE(language_code == 3, null, language_code)
187+
| LOOKUP JOIN languages_lookup_non_unique_key ON language_code
188+
| SORT emp_no
189+
| KEEP emp_no, language_code, language_name
190+
;
191+
192+
emp_no:integer | language_code:integer | language_name:keyword
193+
10001 | 1 | [English, English, English]
194+
10002 | 2 | [German, German, German]
195+
10003 | null | null
196+
;
197+
198+
199+
mvJoinKeyOnTheDataNode
200+
required_capability: join_lookup_v5
201+
202+
FROM employees
203+
| WHERE 10003 < emp_no AND emp_no < 10008
204+
| EVAL language_code = emp_no % 10
205+
| LOOKUP JOIN languages_lookup_non_unique_key ON language_code
206+
| SORT emp_no
207+
| KEEP emp_no, language_code, language_name
208+
;
209+
210+
emp_no:integer | language_code:integer | language_name:keyword
211+
10004 | 4 | Quenya
212+
10005 | 5 | null
213+
10006 | 6 | Mv-Lang
214+
10007 | 7 | [Mv-Lang, Mv-Lang2]
215+
;
216+
217+
mvJoinKeyFromRow
218+
required_capability: join_lookup_v5
219+
220+
ROW language_code = [4, 5, 6, 7]
221+
| LOOKUP JOIN languages_lookup_non_unique_key ON language_code
222+
| EVAL language_name = MV_SORT(language_name), country = MV_SORT(country)
223+
| KEEP language_code, language_name, country
224+
;
225+
226+
language_code:integer | language_name:keyword | country:keyword
227+
[4, 5, 6, 7] | [Mv-Lang, Mv-Lang2, Quenya] | [Atlantis, Mv-Land, Mv-Land2]
228+
;
229+
230+
mvJoinKeyFromRowExpanded
231+
required_capability: join_lookup_v5
232+
233+
ROW language_code = [4, 5, 6, 7, 8]
234+
| MV_EXPAND language_code
235+
| LOOKUP JOIN languages_lookup_non_unique_key ON language_code
236+
| EVAL language_name = MV_SORT(language_name), country = MV_SORT(country)
237+
| KEEP language_code, language_name, country
238+
;
239+
240+
language_code:integer | language_name:keyword | country:keyword
241+
4 | Quenya | null
242+
5 | null | Atlantis
243+
6 | Mv-Lang | Mv-Land
244+
7 | [Mv-Lang, Mv-Lang2] | [Mv-Land, Mv-Land2]
245+
8 | Mv-Lang2 | Mv-Land2
246+
;
247+
181248
lookupIPFromRow
182249
required_capability: join_lookup_v5
183250

0 commit comments

Comments
 (0)