Skip to content

Commit bc6f8cc

Browse files
committed
Test inlinestats after stats with bucket and top
1 parent 0882cbb commit bc6f8cc

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,4 +1190,38 @@ salary:integer |gender:keyword |emp_no:integer |min_sl:integer | x:keyword
11901190
73717 |null |10019 |25324 |null
11911191
;
11921192

1193+
statsBeforeInlinestatsWithTopAndBucket1
1194+
required_capability: inlinestats_v8
1195+
1196+
FROM books
1197+
| STATS avg_rating = AVG(ratings) BY decade = BUCKET(year, 10)
1198+
| INLINESTATS decades = TOP(decade, 3, "DESC")
1199+
| SORT avg_rating DESC
1200+
| LIMIT 10
1201+
;
1202+
1203+
avg_rating:double | decade:double | decades:double
1204+
4.954999923706055 |1960.0 |[2020.0, 2010.0, 2000.0]
1205+
4.387647109873154 |1990.0 |[2020.0, 2010.0, 2000.0]
1206+
4.339166651169459 |2000.0 |[2020.0, 2010.0, 2000.0]
1207+
4.274615342800434 |2010.0 |[2020.0, 2010.0, 2000.0]
1208+
4.063333352406819 |1970.0 |[2020.0, 2010.0, 2000.0]
1209+
3.880000114440918 |2020.0 |[2020.0, 2010.0, 2000.0]
1210+
3.6633334159851074|1980.0 |[2020.0, 2010.0, 2000.0]
1211+
;
1212+
1213+
statsBeforeInlinestatsWithTopAndBucket2
1214+
required_capability: inlinestats_v8
1215+
1216+
FROM sample_data
1217+
| STATS total_duration = SUM(event_duration) BY day = BUCKET(@timestamp, 1 HOUR)
1218+
| INLINESTATS days = TOP(day, 2, "ASC")
1219+
| SORT total_duration ASC
1220+
| LIMIT 5
1221+
;
1222+
1223+
total_duration:long | day:date | days:date
1224+
6215122 |2023-10-23T12:00:00.000Z|[2023-10-23T12:00:00.000Z, 2023-10-23T13:00:00.000Z]
1225+
17016205 |2023-10-23T13:00:00.000Z|[2023-10-23T12:00:00.000Z, 2023-10-23T13:00:00.000Z]
1226+
;
11931227

0 commit comments

Comments
 (0)