Skip to content

Commit 3188967

Browse files
authored
Merge branch 'main' into dense_vector_stats
2 parents 18c6cce + e74c237 commit 3188967

File tree

16 files changed

+190
-161
lines changed

16 files changed

+190
-161
lines changed

test/framework/src/main/java/org/elasticsearch/node/MockNode.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package org.elasticsearch.node;
1111

12+
import org.elasticsearch.action.search.OnlinePrewarmingService;
13+
import org.elasticsearch.action.search.OnlinePrewarmingServiceProvider;
1214
import org.elasticsearch.client.internal.node.NodeClient;
1315
import org.elasticsearch.cluster.ClusterInfoService;
1416
import org.elasticsearch.cluster.MockInternalClusterInfoService;
@@ -117,6 +119,10 @@ SearchService newSearchService(
117119
tracer
118120
);
119121
}
122+
OnlinePrewarmingService onlinePrewarmingService = pluginsService.loadSingletonServiceProvider(
123+
OnlinePrewarmingServiceProvider.class,
124+
() -> OnlinePrewarmingServiceProvider.DEFAULT
125+
).create(clusterService.getSettings(), threadPool, clusterService);
120126
return new MockSearchService(
121127
clusterService,
122128
indicesService,
@@ -126,7 +132,8 @@ SearchService newSearchService(
126132
fetchPhase,
127133
circuitBreakerService,
128134
executorSelector,
129-
tracer
135+
tracer,
136+
onlinePrewarmingService
130137
);
131138
}
132139

test/framework/src/main/java/org/elasticsearch/search/MockSearchService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ public MockSearchService(
8585
FetchPhase fetchPhase,
8686
CircuitBreakerService circuitBreakerService,
8787
ExecutorSelector executorSelector,
88-
Tracer tracer
88+
Tracer tracer,
89+
OnlinePrewarmingService onlinePrewarmingService
8990
) {
9091
super(
9192
clusterService,
@@ -97,7 +98,7 @@ public MockSearchService(
9798
circuitBreakerService,
9899
executorSelector,
99100
tracer,
100-
OnlinePrewarmingService.NOOP
101+
onlinePrewarmingService
101102
);
102103
}
103104

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/MergeOperator.java

Lines changed: 0 additions & 85 deletions
This file was deleted.

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/RrfScoreEvalOperator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ protected Page process(Page page) {
6868
for (int i = 0; i < page.getBlockCount() - 1; i++) {
6969
projections[i] = i == scorePosition ? page.getBlockCount() - 1 : i;
7070
}
71-
72-
return page.projectBlocks(projections);
71+
try {
72+
return page.projectBlocks(projections);
73+
} finally {
74+
page.releaseBlocks();
75+
}
7376
}
7477

7578
@Override

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

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

55
simpleFork
6-
required_capability: fork
6+
required_capability: fork_v3
77

88
FROM employees
99
| FORK ( WHERE emp_no == 10001 )
@@ -18,7 +18,7 @@ emp_no:integer | _fork:keyword
1818
;
1919

2020
forkWithWhereSortAndLimit
21-
required_capability: fork
21+
required_capability: fork_v3
2222

2323
FROM employees
2424
| FORK ( WHERE hire_date < "1985-03-01T00:00:00Z" | SORT first_name | LIMIT 5 )
@@ -38,7 +38,7 @@ emp_no:integer | first_name:keyword | _fork:keyword
3838
;
3939

4040
fiveFork
41-
required_capability: fork
41+
required_capability: fork_v3
4242

4343
FROM employees
4444
| FORK ( WHERE emp_no == 10005 )
@@ -59,7 +59,7 @@ fork5 | 10001
5959
;
6060

6161
forkWithWhereSortDescAndLimit
62-
required_capability: fork
62+
required_capability: fork_v3
6363

6464
FROM employees
6565
| FORK ( WHERE hire_date < "1985-03-01T00:00:00Z" | SORT first_name DESC | LIMIT 2 )
@@ -76,7 +76,7 @@ fork2 | 10087 | Xinglin
7676
;
7777

7878
forkWithCommonPrefilter
79-
required_capability: fork
79+
required_capability: fork_v3
8080

8181
FROM employees
8282
| WHERE emp_no > 10050
@@ -94,7 +94,7 @@ fork2 | 10100
9494
;
9595

9696
forkWithSemanticSearchAndScore
97-
required_capability: fork
97+
required_capability: fork_v3
9898
required_capability: semantic_text_field_caps
9999
required_capability: metadata_score
100100

@@ -114,7 +114,7 @@ fork2 | 6.093784261960139E18 | 2 | all we have to decide is w
114114
;
115115

116116
forkWithEvals
117-
required_capability: fork_v2
117+
required_capability: fork_v3
118118

119119
FROM employees
120120
| FORK (WHERE emp_no == 10048 OR emp_no == 10081 | EVAL x = "abc" | EVAL y = 1)
@@ -131,7 +131,7 @@ fork2 | 10087 | def | null | 2
131131
;
132132

133133
forkWithStats
134-
required_capability: fork_v2
134+
required_capability: fork_v3
135135

136136
FROM employees
137137
| FORK (WHERE emp_no == 10048 OR emp_no == 10081)
@@ -152,7 +152,7 @@ fork4 | null | 100 | 10001 | null
152152
;
153153

154154
forkWithDissect
155-
required_capability: fork_v2
155+
required_capability: fork_v3
156156

157157
FROM employees
158158
| WHERE emp_no == 10048 OR emp_no == 10081
@@ -172,7 +172,7 @@ fork2 | 10081 | Rosen | 10081 | null | Zhongwei
172172
;
173173

174174
forkWithMixOfCommands
175-
required_capability: fork_v2
175+
required_capability: fork_v3
176176

177177
FROM employees
178178
| WHERE emp_no == 10048 OR emp_no == 10081

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ FROM books METADATA _id, _index, _score
7676
( WHERE author:"Ursula K. Le Guin" AND title:"short stories" | SORT _score, _id DESC | LIMIT 3)
7777
| RRF
7878
| STATS count_fork=COUNT(*) BY _fork
79+
| SORT _fork
7980
;
8081

8182
count_fork:long | _fork:keyword
@@ -120,6 +121,7 @@ FROM semantic_text METADATA _id, _score, _index
120121
( WHERE semantic_text_field:"something else" | SORT _score DESC | LIMIT 2)
121122
| RRF
122123
| EVAL _score = round(_score, 4)
124+
| EVAL _fork = mv_sort(_fork)
123125
| KEEP _fork, _score, _id, semantic_text_field
124126
;
125127

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/ForkIT.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,29 @@ private void testSimpleImpl(String query) {
7272
}
7373
}
7474

75+
public void testRow() {
76+
var query = """
77+
ROW a = [1, 2, 3, 4], b = 100
78+
| MV_EXPAND a
79+
| FORK (WHERE a % 2 == 1)
80+
(WHERE a % 2 == 0)
81+
| SORT _fork, a
82+
""";
83+
84+
try (var resp = run(query)) {
85+
assertColumnNames(resp.columns(), List.of("a", "b", "_fork"));
86+
assertColumnTypes(resp.columns(), List.of("integer", "integer", "keyword"));
87+
88+
Iterable<Iterable<Object>> expectedValues = List.of(
89+
List.of(1, 100, "fork1"),
90+
List.of(3, 100, "fork1"),
91+
List.of(2, 100, "fork2"),
92+
List.of(4, 100, "fork2")
93+
);
94+
assertValues(resp.values(), expectedValues);
95+
}
96+
}
97+
7598
public void testSortAndLimitInFirstSubQuery() {
7699
var query = """
77100
FROM test
@@ -216,13 +239,15 @@ public void testWhereSortOnlyInFork() {
216239
( WHERE content:"fox" | SORT id )
217240
( WHERE content:"dog" | SORT id )
218241
| KEEP _fork, id, content
242+
| SORT _fork, id
219243
""";
220244
var queryWithMatchFunction = """
221245
FROM test
222246
| FORK
223247
( WHERE match(content, "fox") | SORT id )
224248
( WHERE match(content, "dog") | SORT id )
225249
| KEEP _fork, id, content
250+
| SORT _fork, id
226251
""";
227252
for (var query : List.of(queryWithMatchOperator, queryWithMatchFunction)) {
228253
try (var resp = run(query)) {
@@ -509,6 +534,7 @@ public void testWithEvalSimple() {
509534
| FORK ( EVAL a = 1 )
510535
( EVAL a = 2 )
511536
| KEEP a, _fork, id, content
537+
| SORT _fork
512538
""";
513539

514540
try (var resp = run(query)) {

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/RrfIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public void testRrf() {
4040
( WHERE content:"fox" | SORT _score, _id DESC )
4141
( WHERE content:"dog" | SORT _score, _id DESC )
4242
| RRF
43+
| EVAL _fork = mv_sort(_fork)
4344
| EVAL _score = round(_score, 4)
4445
| KEEP id, content, _score, _fork
4546
""";

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,9 +983,9 @@ public enum Cap {
983983
MAX_OVER_TIME(Build.current().isSnapshot()),
984984

985985
/**
986-
* Support STATS/EVAL/DISSECT in Fork branches
986+
* Support streaming of sub plan results
987987
*/
988-
FORK_V2(Build.current().isSnapshot()),
988+
FORK_V3(Build.current().isSnapshot()),
989989

990990
/**
991991
* Support for the {@code leading_zeros} named parameter.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/physical/ProjectAwayColumns.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.elasticsearch.xpack.esql.plan.logical.Project;
2020
import org.elasticsearch.xpack.esql.plan.physical.ExchangeExec;
2121
import org.elasticsearch.xpack.esql.plan.physical.FragmentExec;
22+
import org.elasticsearch.xpack.esql.plan.physical.MergeExec;
2223
import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan;
2324
import org.elasticsearch.xpack.esql.rule.Rule;
2425

@@ -45,6 +46,10 @@ public PhysicalPlan apply(PhysicalPlan plan) {
4546

4647
// This will require updating should we choose to have non-unary execution plans in the future.
4748
return plan.transformDown(currentPlanNode -> {
49+
if (currentPlanNode instanceof MergeExec) {
50+
keepTraversing.set(FALSE);
51+
}
52+
4853
if (keepTraversing.get() == false) {
4954
return currentPlanNode;
5055
}

0 commit comments

Comments
 (0)