Skip to content

Commit 1d1bb2b

Browse files
committed
Enable partial results by default in ES|QL
1 parent 4d2cb53 commit 1d1bb2b

File tree

18 files changed

+74
-21
lines changed

18 files changed

+74
-21
lines changed

test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public void testSortByManyLongsTooMuchMemoryAsync() throws IOException {
117117
initManyLongs();
118118
Request request = new Request("POST", "/_query/async");
119119
request.addParameter("error_trace", "");
120+
request.addParameter("allow_partial_results", Boolean.toString(false));
120121
request.setJsonEntity(makeSortByManyLongs(5000).toString().replace("\n", "\\n"));
121122
request.setOptions(
122123
RequestOptions.DEFAULT.toBuilder()
@@ -517,6 +518,7 @@ private Map<String, Object> manyEval(int evalLines) throws IOException {
517518
private Response query(String query, String filterPath) throws IOException {
518519
Request request = new Request("POST", "/_query");
519520
request.addParameter("error_trace", "");
521+
request.addParameter("allow_partial_results", Boolean.toString(false));
520522
if (filterPath != null) {
521523
request.addParameter("filter_path", filterPath);
522524
}

x-pack/plugin/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ tasks.named("yamlRestCompatTestTransform").configure({ task ->
104104
task.skipTest("esql/180_match_operator/match with disjunctions", "Disjunctions in full text functions work now")
105105
task.skipTest("esql/130_spatial/values unsupported for geo_point", "Spatial types are now supported in VALUES aggregation")
106106
task.skipTest("esql/130_spatial/values unsupported for geo_point status code", "Spatial types are now supported in VALUES aggregation")
107+
task.skipTest("esql/63_enrich_int_range/Invalid age as double", "ES|QL now can return partial results instead of failing the query")
107108
// Expected deprecation warning to compat yaml tests:
108109
task.addAllowedWarningRegex(".*rollup functionality will be removed in Elasticsearch.*")
109110
task.skipTest("esql/40_tsdb/from doc with aggregate_metric_double", "TODO: support for subset of metric fields")

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ public final ActionType<Response> action() {
3939

4040
public abstract EsqlQueryRequestBuilder<Request, Response> filter(QueryBuilder filter);
4141

42+
public abstract EsqlQueryRequestBuilder<Request, Response> allowPartialResults(boolean allowPartialResults);
43+
4244
}

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/RestEsqlIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public void testInvalidPragma() throws IOException {
9797
assertOK(client().performRequest(request));
9898
}
9999
RequestObjectBuilder builder = requestObjectBuilder().query("from test-index | limit 1 | keep f");
100+
builder.allPartialResults(false);
100101
builder.pragmas(Settings.builder().put("data_partitioning", "invalid-option").build());
101102
ResponseException re = expectThrows(ResponseException.class, () -> runEsqlSync(builder));
102103
assertThat(EntityUtils.toString(re.getResponse().getEntity()), containsString("No enum constant"));
@@ -107,6 +108,7 @@ public void testInvalidPragma() throws IOException {
107108
public void testPragmaNotAllowed() throws IOException {
108109
assumeFalse("pragma only disabled on release builds", Build.current().isSnapshot());
109110
RequestObjectBuilder builder = requestObjectBuilder().query("row a = 1, b = 2");
111+
builder.allPartialResults(false);
110112
builder.pragmas(Settings.builder().put("data_partitioning", "shard").build());
111113
ResponseException re = expectThrows(ResponseException.class, () -> runEsqlSync(builder));
112114
assertThat(EntityUtils.toString(re.getResponse().getEntity()), containsString("[pragma] only allowed in snapshot builds"));

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public static class RequestObjectBuilder {
127127
private Boolean includeCCSMetadata = null;
128128

129129
private CheckedConsumer<XContentBuilder, IOException> filter;
130+
private Boolean allPartialResults = null;
130131

131132
public RequestObjectBuilder() throws IOException {
132133
this(randomFrom(XContentType.values()));
@@ -204,6 +205,11 @@ public RequestObjectBuilder filter(CheckedConsumer<XContentBuilder, IOException>
204205
return this;
205206
}
206207

208+
public RequestObjectBuilder allPartialResults(boolean allPartialResults) {
209+
this.allPartialResults = allPartialResults;
210+
return this;
211+
}
212+
207213
public RequestObjectBuilder build() throws IOException {
208214
if (isBuilt == false) {
209215
if (tables != null) {
@@ -1151,6 +1157,9 @@ static Request prepareRequestWithOptions(RequestObjectBuilder requestObject, Mod
11511157
requestObject.build();
11521158
Request request = prepareRequest(mode);
11531159
String mediaType = attachBody(requestObject, request);
1160+
if (requestObject.allPartialResults != null) {
1161+
request.addParameter("allow_partial_results", String.valueOf(requestObject.allPartialResults));
1162+
}
11541163

11551164
RequestOptions.Builder options = request.getOptions().toBuilder();
11561165
options.setWarningsHandler(WarningsHandler.PERMISSIVE); // We assert the warnings ourselves

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.elasticsearch.transport.RemoteClusterAware;
2626
import org.elasticsearch.xcontent.XContentBuilder;
2727
import org.elasticsearch.xcontent.json.JsonXContent;
28+
import org.elasticsearch.xpack.esql.plugin.EsqlPlugin;
2829
import org.junit.After;
2930
import org.junit.Before;
3031

@@ -120,6 +121,12 @@ public void releaseLatches() {
120121
CrossClusterAsyncQueryIT.CountingPauseFieldPlugin.release();
121122
}
122123

124+
@Override
125+
protected Settings nodeSettings() {
126+
// TODO: remove this override
127+
return Settings.builder().put(super.nodeSettings()).put(EsqlPlugin.QUERY_ALLOW_PARTIAL_RESULTS.getKey(), false).build();
128+
}
129+
123130
protected void assertClusterInfoSuccess(EsqlExecutionInfo.Cluster cluster, int numShards) {
124131
assertThat(cluster.getTook().millis(), greaterThanOrEqualTo(0L));
125132
assertThat(cluster.getStatus(), equalTo(EsqlExecutionInfo.Cluster.Status.SUCCESSFUL));

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
139139
return CollectionUtils.appendToCopy(super.nodePlugins(), EsqlPlugin.class);
140140
}
141141

142+
@Override
143+
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
144+
return Settings.builder()
145+
.put(super.nodeSettings(nodeOrdinal, otherSettings))
146+
.put(EsqlPlugin.QUERY_ALLOW_PARTIAL_RESULTS.getKey(), false)
147+
.build();
148+
}
149+
142150
protected void setRequestCircuitBreakerLimit(ByteSizeValue limit) {
143151
if (limit != null) {
144152
assertAcked(

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,24 @@ protected EsqlQueryResponse run(EsqlQueryRequest request) {
139139
}
140140
if (randomBoolean()) {
141141
setRequestCircuitBreakerLimit(ByteSizeValue.ofBytes(between(256, 4096)));
142+
EsqlQueryResponse resp = null;
142143
try {
143-
return client.execute(EsqlQueryAction.INSTANCE, request).actionGet(2, TimeUnit.MINUTES);
144+
resp = client.execute(EsqlQueryAction.INSTANCE, request).actionGet(2, TimeUnit.MINUTES);
144145
} catch (Exception e) {
145146
logger.info("request failed", e);
146147
EsqlTestUtils.assertEsqlFailure(e);
147148
ensureBlocksReleased();
148149
} finally {
149150
setRequestCircuitBreakerLimit(null);
150151
}
152+
if (resp != null) {
153+
if (resp.isPartial()) {
154+
resp.close();
155+
assertTrue(request.allowPartialResults());
156+
} else {
157+
return resp;
158+
}
159+
}
151160
}
152161
return client.execute(EsqlQueryAction.INSTANCE, request).actionGet(30, TimeUnit.SECONDS);
153162
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ private EsqlQueryResponse runWithBreaking(EsqlQueryRequest request) throws Circu
113113

114114
@Override
115115
protected EsqlQueryResponse run(EsqlQueryRequest request) {
116-
if (randomBoolean()) {
117-
request.allowPartialResults(randomBoolean());
118-
}
116+
request.allowPartialResults(randomBoolean());
119117
Exception failure = null;
120118
try {
121119
final EsqlQueryResponse resp = runWithBreaking(request);

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ private EsqlQueryResponse runQueryWithDisruption(EsqlQueryRequest request) {
8383
logger.info("--> start disruption scheme [{}]", disruptionScheme);
8484
disruptionScheme.startDisrupting();
8585
logger.info("--> executing esql query with disruption {} ", request.query());
86-
if (randomBoolean()) {
87-
request.allowPartialResults(randomBoolean());
88-
}
86+
request.allowPartialResults(randomBoolean());
8987
ActionFuture<EsqlQueryResponse> future = client().execute(EsqlQueryAction.INSTANCE, request);
9088
EsqlQueryResponse resp = null;
9189
try {

0 commit comments

Comments
 (0)