Skip to content

Commit 26f48e7

Browse files
committed
Add CSV tests
1 parent aa97b8a commit 26f48e7

File tree

1 file changed

+116
-7
lines changed
  • x-pack/plugin/esql/qa/testFixtures/src/main/resources

1 file changed

+116
-7
lines changed

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

Lines changed: 116 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,122 @@ required_capability: knn_function
209209

210210
from colors metadata _score
211211
| eval composed_name = locate(color, " ") > 0
212-
| where knn(rgb_vector, [128,128,0]) and composed_name == false
213-
| keep color, composed_name, _score
212+
| where knn(rgb_vector, [128,128,0]) and composed_name == false
213+
| eval round_score = round(_score, 4)
214+
| keep color, composed_name, round_score
214215
;
215216

216-
color:text | composed_name: boolean | _score: double
217-
olive | false | 1.0
218-
sienna | false | 2.9301168979145586E-4
219-
chocolate | false | 1.4101568376645446E-4
220-
peru | false | 1.3746823242399842E-4
217+
color:text | composed_name:boolean | round_score:double
218+
olive | false | 1.0
219+
sienna | false | 3.0E-4
220+
chocolate | false | 1.0E-4
221+
peru | false | 1.0E-4
221222
;
223+
224+
testKnnWithNonPushableDisjunctions
225+
required_capability: knn_function
226+
227+
from colors metadata _score
228+
| where knn(rgb_vector, [128,128,0], {"k": 5}) or length(color) > 17
229+
| sort _score desc
230+
| eval round_score = round(_score, 4)
231+
| keep color, round_score
232+
;
233+
234+
color:text | round_score: double
235+
olive | 1.0
236+
olive drab | 0.0014
237+
dark olive green | 4.0E-4
238+
dark golden rod | 3.0E-4
239+
sienna | 3.0E-4
240+
medium aqua marine | 0.0
241+
medium spring green | 0.0
242+
light golden rod yellow | 0.0
243+
;
244+
245+
testKnnWithNonPushableDisjunctionsOnComplexExpressions
246+
required_capability: knn_function
247+
248+
from colors metadata _score
249+
| where (knn(rgb_vector, [128,128,0]) and length(color) > 12) or (knn(rgb_vector, [128,0,128]) and primary == false)
250+
| sort _score desc
251+
| eval round_score = round(_score, 4)
252+
| keep color, primary, round_score
253+
;
254+
255+
color: text | primary: boolean | round_score: double
256+
purple | false | 1.0
257+
dark magenta | false | 0.0045
258+
dark olive green | false | 4.0E-4
259+
indigo | false | 4.0E-4
260+
dark golden rod | false | 3.0E-4
261+
dim gray | false | 3.0E-4
262+
dark slate blue | false | 2.0E-4
263+
medium violet red | false | 2.0E-4
264+
dark orchid | false | 1.0E-4
265+
dark violet | false | 1.0E-4
266+
brown | false | 1.0E-4
267+
blue violet | false | 1.0E-4
268+
;
269+
270+
testKnnInStatsNonPushable
271+
required_capability: knn_function
272+
273+
from colors
274+
| where length(color) < 10
275+
| stats c = count(*) where knn(rgb_vector, [128,128,255], {"k": 40})
276+
;
277+
278+
c: long
279+
11
280+
;
281+
282+
283+
testKnnInStatsPushableAndNonPushable
284+
required_capability: knn_function
285+
required_capability: full_text_functions_in_stats_where
286+
287+
from colors metadata _score
288+
| stats c = count(*) where (knn(rgb_vector, [0,255,255], {"k": 40}) or knn(rgb_vector, [0, 0, 255])) and knn(rgb_vector, [0, 255, 0], {"k": 40})
289+
;
290+
291+
c:long
292+
21
293+
;
294+
295+
testKnnInStatsWithGrouping
296+
from colors
297+
| where length(color) < 10
298+
| stats c = count(*) where knn(rgb_vector, [128,128,255], {"k": 40}) by primary
299+
;
300+
301+
c: long | primary: boolean
302+
9 | false
303+
2 | true
304+
;
305+
306+
testKnnInStatsPushable
307+
required_capability: knn_function
308+
required_capability: full_text_functions_in_stats_where
309+
310+
from colors
311+
| stats c = count(*) where knn(rgb_vector, [128,128,255], {"k": 40})
312+
;
313+
314+
# No surprises, gets the number of top k
315+
c:long
316+
40
317+
;
318+
319+
testKnnInStatsWithNonPushableDisjunctions
320+
required_capability: knn_function
321+
required_capability: full_text_functions_in_stats_where
322+
323+
FROM colors
324+
| STATS c = count(*) where knn(rgb_vector, [128,128,0], {"k": 5}) or length(color) > 17
325+
;
326+
327+
c:long
328+
8
329+
;
330+

0 commit comments

Comments
 (0)