Skip to content

Commit f742160

Browse files
Address code review feedback
1 parent 72c3ad7 commit f742160

File tree

5 files changed

+108
-6
lines changed

5 files changed

+108
-6
lines changed

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/command/pipe/LookupJoinGenerator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public CommandDescription generate(
4949
}
5050
EsqlQueryGenerator.Column key = randomFrom(candidateKeys);
5151
if (usedColumns.contains(key.name()) || usedColumns.contains(idxKey)) {
52-
continue; // already used this column, skip
52+
continue; // already used this column from the lookup index, or will discard the main index column by RENAME'ing below, skip
5353
} else {
5454
usedColumns.add(key.name());
5555
usedColumns.add(idxKey);
@@ -74,7 +74,6 @@ public CommandDescription generate(
7474
stringBuilder.append(", ");
7575
}
7676
}
77-
stringBuilder.append("| LIMIT 10");
7877
String cmdString = stringBuilder.toString();
7978
return new CommandDescription(LOOKUP_JOIN, this, cmdString, Map.of());
8079
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ id_int,name_str,is_active_bool,ip_addr,extra1,extra2
1010
9,Ivy,false,192.168.1.9,waldo,900
1111
10,John,true,192.168.1.10,fred,1000
1212
,Kate,false,192.168.1.11,plugh,1100
13-
12,Liam,true,192.168.1.12,xyzzy,1200
13+
[12],Liam,true,192.168.1.12,xyzzy,1200
1414
13,Mia,false,192.168.1.13,thud,1300
15-
14,Nina,true,192.168.1.14,foo2,1400
15+
[14],Nina,true,192.168.1.14,foo2,1400
1616
15,Oscar,false,192.168.1.15,bar2,1500
17+
[17,18],Olivia,true,192.168.1.17,xyz,17000
18+
[1,19,21],Sophia,true,192.168.1.21,zyx,21000

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ id_int,name_str,is_active_bool,ip_addr,other1,other2
1313
,Kate,false,192.168.1.11,mu,12000
1414
12,Liam,true,192.168.1.12,nu,13000
1515
13,Mia,false,192.168.1.13,xi,14000
16-
14,Nina,true,192.168.1.14,omicron,15000
16+
[14],Nina,true,192.168.1.14,omicron,15000
1717
16,Paul,true,192.168.1.16,pi,16000
18+
[17,18],Olivia,true,192.168.1.17,rho,17000
19+
[1,19,20],Sophia,true,192.168.1.21,sigma,21000

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

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4882,9 +4882,13 @@ FROM multi_column_joinable
48824882
| SORT id_int, name_str, extra1, other1, other2
48834883
;
48844884

4885+
warning:Line 2:3: evaluation of [LOOKUP JOIN multi_column_joinable_lookup ON id_int, name_str] failed, treating result as null. Only first 20 failures recorded.
4886+
warning:Line 2:3: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value
4887+
48854888
id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:integer
48864889
1 | Alice | foo | alpha | 1000
48874890
1 | Alice | foo | beta | 2000
4891+
[1, 19, 21] | Sophia | zyx | null | null
48884892
2 | Bob | bar | gamma | 3000
48894893
3 | Charlie | baz | delta | 4000
48904894
3 | Charlie | baz | epsilon | 5000
@@ -4900,9 +4904,50 @@ id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:int
49004904
13 | Mia | thud | xi | 14000
49014905
14 | Nina | foo2 | omicron | 15000
49024906
15 | Oscar | bar2 | null | null
4907+
[17, 18] | Olivia | xyz | null | null
49034908
null | Kate | plugh | null | null
49044909
;
49054910

4911+
lookupJoinOnTwoFieldsSelfJoin
4912+
required_capability: join_lookup_v12
4913+
required_capability: lookup_join_on_multiple_fields
4914+
4915+
FROM multi_column_joinable_lookup
4916+
| LOOKUP JOIN multi_column_joinable_lookup ON id_int, name_str
4917+
| KEEP id_int, name_str, other1, other2
4918+
| SORT id_int, name_str, other1, other2
4919+
;
4920+
4921+
warning:Line 2:3: evaluation of [LOOKUP JOIN multi_column_joinable_lookup ON id_int, name_str] failed, treating result as null. Only first 20 failures recorded.
4922+
warning:Line 2:3: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value
4923+
4924+
id_int:integer | name_str:keyword | other1:keyword | other2:integer
4925+
1 | Alice | alpha | 1000
4926+
1 | Alice | alpha | 1000
4927+
1 | Alice | beta | 2000
4928+
1 | Alice | beta | 2000
4929+
[1, 19, 20] | Sophia | null | null
4930+
2 | Bob | gamma | 3000
4931+
3 | Charlie | delta | 4000
4932+
3 | Charlie | delta | 4000
4933+
3 | Charlie | epsilon | 5000
4934+
3 | Charlie | epsilon | 5000
4935+
4 | David | zeta | 6000
4936+
5 | Eve | eta | 7000
4937+
5 | Eve | eta | 7000
4938+
5 | Eve | theta | 8000
4939+
5 | Eve | theta | 8000
4940+
6 | null | null | null
4941+
7 | Grace | kappa | 10000
4942+
8 | Hank | lambda | 11000
4943+
12 | Liam | nu | 13000
4944+
13 | Mia | xi | 14000
4945+
14 | Nina | omicron | 15000
4946+
16 | Paul | pi | 16000
4947+
[17, 18] | Olivia | null | null
4948+
null | Kate | null | null
4949+
;
4950+
49064951
lookupJoinOnThreeFields
49074952
required_capability: join_lookup_v12
49084953
required_capability: lookup_join_on_multiple_fields
@@ -4913,9 +4958,13 @@ FROM multi_column_joinable
49134958
| SORT id_int, name_str, extra1, other1, other2
49144959
;
49154960

4961+
warning:Line 2:3: evaluation of [LOOKUP JOIN multi_column_joinable_lookup ON id_int, name_str, is_active_bool] failed, treating result as null. Only first 20 failures recorded.
4962+
warning:Line 2:3: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value
4963+
49164964
id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:integer
49174965
1 | Alice | foo | alpha | 1000
49184966
1 | Alice | foo | beta | 2000
4967+
[1, 19, 21] | Sophia | zyx | null | null
49194968
2 | Bob | bar | gamma | 3000
49204969
3 | Charlie | baz | delta | 4000
49214970
4 | David | qux | zeta | 6000
@@ -4930,6 +4979,7 @@ id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:int
49304979
13 | Mia | thud | xi | 14000
49314980
14 | Nina | foo2 | omicron | 15000
49324981
15 | Oscar | bar2 | null | null
4982+
[17, 18] | Olivia | xyz | null | null
49334983
null | Kate | plugh | null | null
49344984
;
49354985

@@ -4944,8 +4994,12 @@ FROM multi_column_joinable
49444994
| SORT id_int, name_str, extra1, other1, other2
49454995
;
49464996

4997+
warning:Line 2:3: evaluation of [LOOKUP JOIN multi_column_joinable_lookup ON id_int, name_str, is_active_bool, ip_addr] failed, treating result as null. Only first 20 failures recorded.
4998+
warning:Line 2:3: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value
4999+
49475000
id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:integer
49485001
1 | Alice | foo | alpha | 1000
5002+
[1, 19, 21] | Sophia | zyx | null | null
49495003
2 | Bob | bar | null | null
49505004
3 | Charlie | baz | delta | 4000
49515005
4 | David | qux | zeta | 6000
@@ -4960,6 +5014,7 @@ id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:int
49605014
13 | Mia | thud | xi | 14000
49615015
14 | Nina | foo2 | omicron | 15000
49625016
15 | Oscar | bar2 | null | null
5017+
[17, 18] | Olivia | xyz | null | null
49635018
null | Kate | plugh | null | null
49645019
;
49655020

@@ -4976,6 +5031,7 @@ FROM multi_column_joinable
49765031

49775032
id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:integer | is_active_bool:boolean | ip_addr:ip
49785033
1 | Alice | foo | alpha | 1000 | true | 192.168.1.1
5034+
[1, 19, 20] | Sophia | zyx | sigma | 21000 | true | 192.168.1.21
49795035
3 | Charlie | baz | delta | 4000 | true | 192.168.1.3
49805036
4 | David | qux | zeta | 6000 | false | 192.168.1.4
49815037
5 | Eve | quux | eta | 7000 | true | 192.168.1.5
@@ -4985,6 +5041,7 @@ id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:int
49855041
12 | Liam | xyzzy | nu | 13000 | true | 192.168.1.12
49865042
13 | Mia | thud | xi | 14000 | false | 192.168.1.13
49875043
14 | Nina | foo2 | omicron | 15000 | true | 192.168.1.14
5044+
[17, 18] | Olivia | xyz | rho | 17000 | true | 192.168.1.17
49885045
null | Kate | plugh | mu | 12000 | false | 192.168.1.11
49895046
null | null | bar | null | null | false | 192.168.1.2
49905047
null | null | bar2 | null | null | false | 192.168.1.15
@@ -5004,6 +5061,11 @@ FROM multi_column_joinable
50045061
| SORT id_int, name_str, extra1, other1, other2
50055062
;
50065063

5064+
warning:Line 2:17: evaluation of [id_int + 5] failed, treating result as null. Only first 20 failures recorded.
5065+
warning:Line 2:17: java.lang.IllegalArgumentException: single-value function encountered multi-value
5066+
warning:Line 3:3: evaluation of [LOOKUP JOIN multi_column_joinable_lookup ON id_int, is_active_bool] failed, treating result as null. Only first 20 failures recorded.
5067+
warning:Line 3:3: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value
5068+
50075069
id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:integer
50085070
6 | null | foo | iota | 9000
50095071
7 | Grace | bar | kappa | 10000
@@ -5020,6 +5082,8 @@ id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:int
50205082
19 | null | foo2 | null | null
50215083
20 | null | bar2 | null | null
50225084
null | null | plugh | null | null
5085+
null | null | xyz | null | null
5086+
null | null | zyx | null | null
50235087
;
50245088

50255089

@@ -5037,6 +5101,9 @@ FROM multi_column_joinable
50375101
| SORT id_int, name_str, extra1, other1, other2
50385102
;
50395103

5104+
warning:Line 4:3: evaluation of [LOOKUP JOIN multi_column_joinable_lookup ON id_int, is_active_bool] failed, treating result as null. Only first 20 failures recorded.
5105+
warning:Line 4:3: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value
5106+
50405107
id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:integer
50415108
1 | Alice | foo | alpha | 1000
50425109
1 | Alice | foo | beta | 2000
@@ -5050,3 +5117,35 @@ id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:int
50505117
15 | null | bar2 | null | null
50515118
null | null | plugh | null | null
50525119
;
5120+
5121+
5122+
lookupJoinOnTwoFieldsMultipleTimes
5123+
required_capability: join_lookup_v12
5124+
required_capability: lookup_join_on_multiple_fields
5125+
5126+
FROM multi_column_joinable
5127+
| LOOKUP JOIN multi_column_joinable_lookup ON id_int, is_active_bool
5128+
| SORT extra1
5129+
| LIMIT 10
5130+
| LOOKUP JOIN multi_column_joinable_lookup ON name_str, is_active_bool
5131+
| KEEP id_int, name_str, extra1, other1, other2
5132+
| SORT id_int, name_str, extra1, other1, other2
5133+
;
5134+
5135+
warning:Line 2:3: evaluation of [LOOKUP JOIN multi_column_joinable_lookup ON id_int, is_active_bool] failed, treating result as null. Only first 20 failures recorded.
5136+
warning:Line 2:3: java.lang.IllegalArgumentException: LOOKUP JOIN encountered multi-value
5137+
5138+
id_int:integer | name_str:keyword | extra1:keyword | other1:keyword | other2:integer
5139+
1 | Alice | foo | alpha | 1000
5140+
1 | Alice | foo | alpha | 1000
5141+
1 | Alice | foo | beta | 2000
5142+
1 | Alice | foo | beta | 2000
5143+
2 | Bob | bar | gamma | 3000
5144+
3 | Charlie | baz | delta | 4000
5145+
7 | Grace | grault | kappa | 10000
5146+
8 | Hank | garply | lambda | 11000
5147+
14 | Nina | foo2 | omicron | 15000
5148+
null | null | bar2 | null | null
5149+
null | null | corge | null | null
5150+
null | null | fred | null | null
5151+
;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ setup:
113113
- { "index": { } }
114114
- { "key": 1, "color": "red" }
115115
- { "index": { } }
116-
- { "key": 2, "color": "yellow" }
116+
- { "key": 2, "color": "blue" }
117117
- do:
118118
bulk:
119119
index: "test-lookup-1"

0 commit comments

Comments
 (0)