Skip to content

Commit 3963fd3

Browse files
committed
Add CSV tests for STATS
1 parent dfce035 commit 3963fd3

File tree

3 files changed

+175
-0
lines changed

3 files changed

+175
-0
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/resources/kql-function.csv-spec

+54
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ c:long
203203
3
204204
;
205205

206+
207+
testMatchInStatsPushableAndNonPushable
208+
required_capability: kql_function
209+
required_capability: full_text_functions_in_stats_where
210+
211+
from books
212+
| stats c = count(*) where (kql("title: lord") and ratings > 4.5) or (kql("author: dostoevsky") and length(title) > 50)
213+
;
214+
215+
c:long
216+
6
217+
;
218+
206219
testKqlInStatsPushable
207220
required_capability: kql_function
208221
required_capability: full_text_functions_in_stats_where
@@ -214,3 +227,44 @@ from books
214227
c:long
215228
22
216229
;
230+
231+
testKqlInStatsWithNonPushableDisjunctions
232+
required_capability: kql_function
233+
required_capability: full_text_functions_in_stats_where
234+
FROM books
235+
| STATS c = count(*) where kql("title: lord") or length(title) > 130
236+
;
237+
238+
c:long
239+
5
240+
;
241+
242+
testKqlInStatsWithMultipleAggs
243+
required_capability: kql_function
244+
required_capability: full_text_functions_in_stats_where
245+
FROM books
246+
| STATS c = count(*) where kql("title: lord"), m = max(book_no::integer) where kql("author: tolkien"), n = min(book_no::integer) where kql("author: dostoevsky")
247+
;
248+
249+
c:long | m:integer | n:integer
250+
4 | 9607 | 1211
251+
;
252+
253+
254+
testKqlInStatsWithGrouping
255+
required_capability: kql_function
256+
required_capability: full_text_functions_in_stats_where
257+
FROM books
258+
| STATS r = AVG(ratings) where kql("title: Lord AND Rings") by author | WHERE r is not null
259+
;
260+
ignoreOrder: true
261+
262+
r:double | author: text
263+
4.75 | Alan Lee
264+
4.674999952316284 | J. R. R. Tolkien
265+
4.670000076293945 | John Ronald Reuel Tolkien
266+
4.670000076293945 | Agnes Perkins
267+
4.670000076293945 | Charles Adolph Huttar
268+
4.670000076293945 | Walter Scheps
269+
4.559999942779541 | J.R.R. Tolkien
270+
;

x-pack/plugin/esql/qa/testFixtures/src/main/resources/match-function.csv-spec

+61
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,18 @@ c:long
764764
3
765765
;
766766

767+
testMatchInStatsPushableAndNonPushable
768+
required_capability: match_function
769+
required_capability: full_text_functions_in_stats_where
770+
771+
from books
772+
| stats c = count(*) where (match(title, "lord") and ratings > 4.5) or (match(author, "dostoevsky") and length(title) > 50)
773+
;
774+
775+
c:long
776+
6
777+
;
778+
767779
testMatchInStatsPushable
768780
required_capability: match_function
769781
required_capability: full_text_functions_in_stats_where
@@ -776,3 +788,52 @@ c:long
776788
22
777789
;
778790

791+
testMatchInStatsWithOptions
792+
FROM books
793+
| STATS c = count(*) where match(title, "Hobbit Back Again", {"operator": "AND"})
794+
;
795+
796+
c:long
797+
1
798+
;
799+
800+
testMatchInStatsWithNonPushableDisjunctions
801+
required_capability: match_function
802+
required_capability: full_text_functions_in_stats_where
803+
FROM books
804+
| STATS c = count(*) where match(title, "lord") or length(title) > 130
805+
;
806+
807+
c:long
808+
5
809+
;
810+
811+
testMatchInStatsWithMultipleAggs
812+
required_capability: match_function
813+
required_capability: full_text_functions_in_stats_where
814+
FROM books
815+
| STATS c = count(*) where match(title, "lord"), m = max(book_no::integer) where match(author, "tolkien"), n = min(book_no::integer) where match(author, "dostoevsky")
816+
;
817+
818+
c:long | m:integer | n:integer
819+
4 | 9607 | 1211
820+
;
821+
822+
823+
testMatchInStatsWithGrouping
824+
required_capability: match_function
825+
required_capability: full_text_functions_in_stats_where
826+
FROM books
827+
| STATS r = AVG(ratings) where match(title, "Lord Rings", {"operator": "AND"}) by author | WHERE r is not null
828+
;
829+
ignoreOrder: true
830+
831+
r:double | author: text
832+
4.75 | Alan Lee
833+
4.674999952316284 | J. R. R. Tolkien
834+
4.670000076293945 | John Ronald Reuel Tolkien
835+
4.670000076293945 | Agnes Perkins
836+
4.670000076293945 | Charles Adolph Huttar
837+
4.670000076293945 | Walter Scheps
838+
4.559999942779541 | J.R.R. Tolkien
839+
;

x-pack/plugin/esql/qa/testFixtures/src/main/resources/qstr-function.csv-spec

+60
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,18 @@ c:long
224224
3
225225
;
226226

227+
testMatchInStatsPushableAndNonPushable
228+
required_capability: qstr_function
229+
required_capability: full_text_functions_in_stats_where
230+
231+
from books
232+
| stats c = count(*) where (qstr("title: lord") and ratings > 4.5) or (qstr("author: dostoevsky") and length(title) > 50)
233+
;
234+
235+
c:long
236+
6
237+
;
238+
227239
testQstrInStatsPushable
228240
required_capability: qstr_function
229241
required_capability: full_text_functions_in_stats_where
@@ -236,3 +248,51 @@ c:long
236248
22
237249
;
238250

251+
testQstrInStatsWithOptions
252+
FROM books
253+
| STATS c = count(*) where qstr("title: Hobbit Back Again", {"default_operator": "AND"})
254+
;
255+
256+
c:long
257+
1
258+
;
259+
260+
testQstrInStatsWithNonPushableDisjunctions
261+
required_capability: qstr_function
262+
required_capability: full_text_functions_in_stats_where
263+
FROM books
264+
| STATS c = count(*) where qstr("title: lord") or length(title) > 130
265+
;
266+
267+
c:long
268+
5
269+
;
270+
271+
testQstrInStatsWithMultipleAggs
272+
required_capability: qstr_function
273+
required_capability: full_text_functions_in_stats_where
274+
FROM books
275+
| STATS c = count(*) where qstr("title: lord"), m = max(book_no::integer) where qstr("author: tolkien"), n = min(book_no::integer) where qstr("author: dostoevsky")
276+
;
277+
278+
c:long | m:integer | n:integer
279+
4 | 9607 | 1211
280+
;
281+
282+
testQstrInStatsWithGrouping
283+
required_capability: qstr_function
284+
required_capability: full_text_functions_in_stats_where
285+
FROM books
286+
| STATS r = AVG(ratings) where qstr("title: Lord Rings", {"default_operator": "AND"}) by author | WHERE r is not null
287+
;
288+
ignoreOrder: true
289+
290+
r:double | author: text
291+
4.75 | Alan Lee
292+
4.674999952316284 | J. R. R. Tolkien
293+
4.670000076293945 | John Ronald Reuel Tolkien
294+
4.670000076293945 | Agnes Perkins
295+
4.670000076293945 | Charles Adolph Huttar
296+
4.670000076293945 | Walter Scheps
297+
4.559999942779541 | J.R.R. Tolkien
298+
;

0 commit comments

Comments
 (0)