Skip to content

Commit 04c8bf4

Browse files
authored
ESQL: Revive some more of inlinestats functionality (elastic#123589)
1 parent 2a006ec commit 04c8bf4

File tree

9 files changed

+182
-99
lines changed

9 files changed

+182
-99
lines changed

docs/changelog/123589.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 123589
2+
summary: Revive some more of inlinestats functionality
3+
area: ES|QL
4+
type: bug
5+
issues: []

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import static org.elasticsearch.xpack.esql.EsqlTestUtils.classpathResources;
4949
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS;
5050
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS_V2;
51-
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS_V3;
51+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS_V4;
5252
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V12;
5353
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_PLANNING_V1;
5454
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.METADATA_FIELDS_REMOTE_TEST;
@@ -126,7 +126,7 @@ protected void shouldSkipTest(String testName) throws IOException {
126126
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(INLINESTATS.capabilityName()));
127127
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(INLINESTATS_V2.capabilityName()));
128128
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(JOIN_PLANNING_V1.capabilityName()));
129-
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(INLINESTATS_V3.capabilityName()));
129+
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(INLINESTATS_V4.capabilityName()));
130130
assumeFalse("LOOKUP JOIN not yet supported in CCS", testCase.requiredCapabilities.contains(JOIN_LOOKUP_V12.capabilityName()));
131131
// Unmapped fields require a coorect capability response from every cluster, which isn't currently implemented.
132132
assumeFalse("UNMAPPED FIELDS not yet supported in CCS", testCase.requiredCapabilities.contains(UNMAPPED_FIELDS.capabilityName()));

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

Lines changed: 115 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44

55
maxOfInt
6-
required_capability: inlinestats_v3
6+
required_capability: inlinestats_v4
77
// tag::max-languages[]
88
FROM employees
99
| KEEP emp_no, languages
@@ -25,7 +25,7 @@ emp_no:integer | languages:integer | max_lang:integer
2525
;
2626

2727
maxOfIntByKeyword
28-
required_capability: inlinestats_v3
28+
required_capability: inlinestats_v4
2929

3030
FROM employees
3131
| KEEP emp_no, languages, gender
@@ -34,31 +34,31 @@ FROM employees
3434
| SORT emp_no ASC
3535
| LIMIT 5;
3636

37-
emp_no:integer | languages:integer | gender:keyword | max_lang:integer
38-
10002 | 5 | F | 5
39-
10004 | 5 | M | 5
40-
10011 | 5 | null | 5
41-
10012 | 5 | null | 5
42-
10014 | 5 | null | 5
37+
emp_no:integer | languages:integer | max_lang:integer | gender:keyword
38+
10002 | 5 | 5 | F
39+
10004 | 5 | 5 | M
40+
10011 | 5 | 5 | null
41+
10012 | 5 | 5 | null
42+
10014 | 5 | 5 | null
4343
;
4444

4545
maxOfLongByKeyword
46-
required_capability: inlinestats_v3
46+
required_capability: inlinestats_v4
4747

4848
FROM employees
4949
| KEEP emp_no, avg_worked_seconds, gender
5050
| INLINESTATS max_avg_worked_seconds = MAX(avg_worked_seconds) BY gender
5151
| WHERE max_avg_worked_seconds == avg_worked_seconds
5252
| SORT emp_no ASC;
5353

54-
emp_no:integer | avg_worked_seconds:long | gender:keyword | max_avg_worked_seconds:long
55-
10007 | 393084805 | F | 393084805
56-
10015 | 390266432 | null | 390266432
57-
10030 | 394597613 | M | 394597613
54+
emp_no:integer | avg_worked_seconds:long | max_avg_worked_seconds:long | gender:keyword
55+
10007 | 393084805 | 393084805 | F
56+
10015 | 390266432 | 390266432 | null
57+
10030 | 394597613 | 394597613 | M
5858
;
5959

6060
maxOfLong
61-
required_capability: inlinestats_v3
61+
required_capability: inlinestats_v4
6262

6363
FROM employees
6464
| KEEP emp_no, avg_worked_seconds, gender
@@ -71,7 +71,7 @@ emp_no:integer | avg_worked_seconds:long | gender:keyword | max_avg_worked_secon
7171
;
7272

7373
maxOfLongByCalculatedKeyword
74-
required_capability: inlinestats_v3
74+
required_capability: inlinestats_v4
7575

7676
// tag::longest-tenured-by-first[]
7777
FROM employees
@@ -84,17 +84,17 @@ FROM employees
8484
;
8585

8686
// tag::longest-tenured-by-first-result[]
87-
emp_no:integer | avg_worked_seconds:long | last_name:keyword | SUBSTRING(last_name, 0, 1):keyword | max_avg_worked_seconds:long
88-
10065 | 372660279 | Awdeh | A | 372660279
89-
10074 | 382397583 | Bernatsky | B | 382397583
90-
10044 | 387408356 | Casley | C | 387408356
91-
10030 | 394597613 | Demeyer | D | 394597613
92-
10087 | 305782871 | Eugenio | E | 305782871
87+
emp_no:integer | avg_worked_seconds:long | last_name:keyword | max_avg_worked_seconds:long | SUBSTRING(last_name, 0, 1):keyword
88+
10065 | 372660279 | Awdeh | 372660279 | A
89+
10074 | 382397583 | Bernatsky | 382397583 | B
90+
10044 | 387408356 | Casley | 387408356 | C
91+
10030 | 394597613 | Demeyer | 394597613 | D
92+
10087 | 305782871 | Eugenio | 305782871 | E
9393
// end::longest-tenured-by-first-result[]
9494
;
9595

9696
maxOfLongByCalculatedNamedKeyword
97-
required_capability: inlinestats_v3
97+
required_capability: inlinestats_v4
9898

9999
FROM employees
100100
| KEEP emp_no, avg_worked_seconds, last_name
@@ -104,16 +104,16 @@ FROM employees
104104
| LIMIT 5
105105
;
106106

107-
emp_no:integer | avg_worked_seconds:long | last_name:keyword | l:keyword | max_avg_worked_seconds:long
108-
10065 | 372660279 | Awdeh | A | 372660279
109-
10074 | 382397583 | Bernatsky | B | 382397583
110-
10044 | 387408356 | Casley | C | 387408356
111-
10030 | 394597613 | Demeyer | D | 394597613
112-
10087 | 305782871 | Eugenio | E | 305782871
107+
emp_no:integer | avg_worked_seconds:long | last_name:keyword | max_avg_worked_seconds:long | l:keyword
108+
10065 | 372660279 | Awdeh | 372660279 | A
109+
10074 | 382397583 | Bernatsky | 382397583 | B
110+
10044 | 387408356 | Casley | 387408356 | C
111+
10030 | 394597613 | Demeyer | 394597613 | D
112+
10087 | 305782871 | Eugenio | 305782871 | E
113113
;
114114

115-
maxOfLongByCalculatedDroppedKeyword-Ignore
116-
required_capability: join_planning_v1
115+
maxOfLongByCalculatedDroppedKeyword
116+
required_capability: inlinestats_v4
117117

118118
FROM employees
119119
| INLINESTATS max_avg_worked_seconds = MAX(avg_worked_seconds) BY l = SUBSTRING(last_name, 0, 1)
@@ -132,7 +132,7 @@ emp_no:integer | avg_worked_seconds:long | last_name:keyword | max_avg_worked_se
132132
;
133133

134134
maxOfLongByEvaledKeyword
135-
required_capability: inlinestats_v3
135+
required_capability: inlinestats_v4
136136

137137
FROM employees
138138
| EVAL l = SUBSTRING(last_name, 0, 1)
@@ -143,34 +143,34 @@ FROM employees
143143
| LIMIT 5
144144
;
145145

146-
emp_no:integer | avg_worked_seconds:long | l:keyword | max_avg_worked_seconds:long
147-
10065 | 372660279 | A | 372660279
148-
10074 | 382397583 | B | 382397583
149-
10044 | 387408356 | C | 387408356
150-
10030 | 394597613 | D | 394597613
151-
10087 | 305782871 | E | 305782871
146+
emp_no:integer | avg_worked_seconds:long | max_avg_worked_seconds:long | l:keyword
147+
10065 | 372660279 | 372660279 | A
148+
10074 | 382397583 | 382397583 | B
149+
10044 | 387408356 | 387408356 | C
150+
10030 | 394597613 | 394597613 | D
151+
10087 | 305782871 | 305782871 | E
152152
;
153153

154154
maxOfLongByInt
155-
required_capability: inlinestats_v3
155+
required_capability: inlinestats_v4
156156

157157
FROM employees
158158
| KEEP emp_no, avg_worked_seconds, languages
159159
| INLINESTATS max_avg_worked_seconds = MAX(avg_worked_seconds) BY languages
160160
| WHERE max_avg_worked_seconds == avg_worked_seconds
161161
| SORT languages ASC;
162162

163-
emp_no:integer | avg_worked_seconds:long | languages:integer | max_avg_worked_seconds:long
164-
10044 | 387408356 | 1 | 387408356
165-
10099 | 377713748 | 2 | 377713748
166-
10030 | 394597613 | 3 | 394597613
167-
10007 | 393084805 | 4 | 393084805
168-
10015 | 390266432 | 5 | 390266432
169-
10027 | 374037782 | null | 374037782
163+
emp_no:integer | avg_worked_seconds:long | max_avg_worked_seconds:long | languages:integer
164+
10044 | 387408356 | 387408356 | 1
165+
10099 | 377713748 | 377713748 | 2
166+
10030 | 394597613 | 394597613 | 3
167+
10007 | 393084805 | 393084805 | 4
168+
10015 | 390266432 | 390266432 | 5
169+
10027 | 374037782 | 374037782 | null
170170
;
171171

172172
maxOfLongByIntDouble
173-
required_capability: inlinestats_v3
173+
required_capability: inlinestats_v4
174174

175175
FROM employees
176176
| KEEP emp_no, avg_worked_seconds, languages, height
@@ -180,11 +180,11 @@ FROM employees
180180
| SORT languages, height ASC
181181
| LIMIT 4;
182182

183-
emp_no:integer | avg_worked_seconds:long | languages:integer | height:double | max_avg_worked_seconds:long
184-
10083 | 331236443 | 1 | 1.4 | 331236443
185-
10084 | 359067056 | 1 | 1.5 | 359067056
186-
10033 | 208374744 | 1 | 1.6 | 208374744
187-
10086 | 328580163 | 1 | 1.7 | 328580163
183+
emp_no:integer | avg_worked_seconds:long | max_avg_worked_seconds:long | languages:integer | height:double
184+
10083 | 331236443 | 331236443 | 1 | 1.4
185+
10084 | 359067056 | 359067056 | 1 | 1.5
186+
10033 | 208374744 | 208374744 | 1 | 1.6
187+
10086 | 328580163 | 328580163 | 1 | 1.7
188188
;
189189

190190

@@ -243,8 +243,8 @@ abbrev:keyword | type:keyword | scalerank:integer | min_scalerank:integer
243243
// end::mv-expand-result[]
244244
;
245245

246-
byMvExpand-Ignore
247-
required_capability: join_planning_v1
246+
byMvExpand
247+
required_capability: inlinestats_v4
248248

249249
// tag::extreme-airports[]
250250
FROM airports
@@ -307,8 +307,8 @@ count:long | country:keyword | avg:double
307307
17 | United Kingdom | 4.455
308308
;
309309

310-
afterWhere-Ignore
311-
required_capability: join_planning_v1
310+
afterWhere
311+
required_capability: inlinestats_v4
312312

313313
FROM airports
314314
| WHERE country != "United States"
@@ -367,7 +367,7 @@ abbrev:keyword | city:keyword | region:text | "COUNT(*)":long
367367
;
368368

369369
beforeStats
370-
required_capability: inlinestats_v3
370+
required_capability: inlinestats_v4
371371

372372
FROM airports
373373
| EVAL lat = ST_Y(location)
@@ -379,8 +379,8 @@ northern:long | southern:long
379379
520 | 371
380380
;
381381

382-
beforeKeepSort-Ignore
383-
required_capability: join_planning_v1
382+
beforeKeepSort
383+
required_capability: inlinestats_v4
384384

385385
FROM employees
386386
| INLINESTATS max_salary = MAX(salary) by languages
@@ -500,8 +500,8 @@ city:keyword | x:keyword
500500
Zürich | Zürich
501501
;
502502

503-
byConstant-Ignore
504-
required_capability: join_planning_v1
503+
byConstant
504+
required_capability: inlinestats_v4
505505

506506
FROM employees
507507
| KEEP emp_no, languages
@@ -520,7 +520,7 @@ emp_no:integer | languages:integer | max_lang:integer | y:integer
520520
;
521521

522522
aggConstant
523-
required_capability: join_planning_v1
523+
required_capability: inlinestats_v4
524524

525525
FROM employees
526526
| KEEP emp_no
@@ -529,16 +529,16 @@ FROM employees
529529
| LIMIT 5
530530
;
531531

532-
emp_no:integer | one:integer
533-
10001 | 1
534-
10002 | 1
535-
10003 | 1
536-
10004 | 1
537-
10005 | 1
532+
one:integer | emp_no:integer
533+
1 | 10001
534+
1 | 10002
535+
1 | 10003
536+
1 | 10004
537+
1 | 10005
538538
;
539539

540540
percentile
541-
required_capability: inlinestats_v3
541+
required_capability: inlinestats_v4
542542

543543
FROM employees
544544
| KEEP emp_no, salary
@@ -557,7 +557,7 @@ emp_no:integer | salary:integer | ninety_fifth_salary:double
557557
;
558558

559559
byTwoCalculated
560-
required_capability: join_planning_v1
560+
required_capability: inlinestats_v4
561561

562562
FROM airports
563563
| WHERE abbrev IS NOT NULL
@@ -569,10 +569,10 @@ FROM airports
569569
| LIMIT 3
570570
;
571571

572-
abbrev:keyword | scalerank:integer | location:geo_point | lat_10:double | lon_10:double | min_sl:integer
573-
ZRH | 3 | POINT(8.56221279534765 47.4523895064915) | 50 | 10 | 2
574-
ZNZ | 4 | POINT (39.2223319841558 -6.21857034620282) | -10 | 40 | 4
575-
ZLO | 7 | POINT (-104.560095200097 19.1480860285854) | 20 | -100 | 2
572+
abbrev:keyword | scalerank:integer | location:geo_point | min_sl:integer | lat_10:double | lon_10:double
573+
ZRH | 3 | POINT(8.56221279534765 47.4523895064915) | 2 | 50 | 10
574+
ZNZ | 4 | POINT (39.2223319841558 -6.21857034620282) | 4 | -10 | 40
575+
ZLO | 7 | POINT (-104.560095200097 19.1480860285854) | 2 | 20 | -100
576576
;
577577

578578
byTwoCalculatedSecondOverwrites-Ignore
@@ -642,7 +642,7 @@ abbrev:keyword | scalerank:integer | location:geo_point
642642
;
643643

644644
groupShadowsField
645-
required_capability: join_planning_v1
645+
required_capability: inlinestats_v4
646646

647647
FROM employees
648648
| KEEP emp_no, salary, hire_date
@@ -653,9 +653,45 @@ required_capability: join_planning_v1
653653
| LIMIT 4
654654
;
655655

656-
emp_no:integer | salary:integer | hire_date:datetime | avg_salary:double
657-
10001 | 57305 | 1986-01-01T00:00:00Z | 43869.63636363636
658-
10002 | 56371 | 1985-01-01T00:00:00Z | 51831.818181818184
659-
10003 | 61805 | 1986-01-01T00:00:00Z | 43869.63636363636
660-
10005 | 63528 | 1989-01-01T00:00:00Z | 53487.07692307692
656+
emp_no:integer | salary:integer | avg_salary:double | hire_date:datetime
657+
10001 | 57305 | 43869.63636363636 | 1986-01-01T00:00:00Z
658+
10002 | 56371 | 51831.818181818184| 1985-01-01T00:00:00Z
659+
10003 | 61805 | 43869.63636363636 | 1986-01-01T00:00:00Z
660+
10005 | 63528 | 53487.07692307692 | 1989-01-01T00:00:00Z
661+
;
662+
663+
groupByExpression_And_ExistentField
664+
required_capability: inlinestats_v4
665+
FROM employees
666+
| KEEP emp_no, languages, gender
667+
| EVAL x = "ABC"
668+
| INLINESTATS max_lang = MAX(languages) BY y = to_lower(x), gender
669+
| SORT emp_no ASC
670+
| LIMIT 5
671+
;
672+
673+
emp_no:integer | languages:integer | x:keyword | max_lang:integer | y:keyword | gender:keyword
674+
10001 |2 |ABC |5 |abc |M
675+
10002 |5 |ABC |5 |abc |F
676+
10003 |4 |ABC |5 |abc |M
677+
10004 |5 |ABC |5 |abc |M
678+
10005 |1 |ABC |5 |abc |M
679+
;
680+
681+
groupByRenamedColumn-Ignore
682+
required_capability: inlinestats_v4
683+
FROM employees
684+
| KEEP emp_no, languages, gender
685+
| INLINESTATS max_lang = MAX(languages) BY y = gender
686+
| WHERE max_lang == languages
687+
| SORT emp_no ASC
688+
| LIMIT 5
689+
;
690+
691+
emp_no:integer | languages:integer | gender:keyword | max_lang:integer | y:keyword
692+
10002 | 5 | F | 5 | F
693+
10004 | 5 | M | 5 | M
694+
10011 | 5 | null | 5 | null
695+
10012 | 5 | null | 5 | null
696+
10014 | 5 | null | 5 | null
661697
;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ public enum Cap {
835835
* Fixes a series of issues with inlinestats which had an incomplete implementation after lookup and inlinestats
836836
* were refactored.
837837
*/
838-
INLINESTATS_V3(EsqlPlugin.INLINESTATS_FEATURE_FLAG),
838+
INLINESTATS_V4(EsqlPlugin.INLINESTATS_FEATURE_FLAG),
839839

840840
/**
841841
* Support partial_results

0 commit comments

Comments
 (0)