Skip to content

Commit eb479e5

Browse files
authored
Allow partial results by default in ES|QL - Take 2 (#127351)
* Revert "ESQL: Revert "Allow partial results by default in ES|QL (#125060)" (#126286)" This reverts commit 8f38b13. Restore changes from #125060 now that the breakage should be fixed.
1 parent bdb70c0 commit eb479e5

File tree

17 files changed

+86
-68
lines changed

17 files changed

+86
-68
lines changed

docs/changelog/126286.yaml

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

docs/changelog/127351.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pr: 127351
2+
summary: Allow partial results by default in ES|QL
3+
area: ES|QL
4+
type: breaking
5+
issues: [122802]
6+
7+
breaking:
8+
title: Allow partial results by default in ES|QL
9+
area: ES|QL
10+
details: >-
11+
In earlier versions of {es}, ES|QL would fail the entire query if it encountered any error. ES|QL now returns partial results instead of failing when encountering errors.
12+
13+
impact: >-
14+
Callers should check the `is_partial` flag returned in the response to determine if the result is partial or complete. If returning partial results is not desired, this option can be overridden per request via an `allow_partial_results` parameter in the query URL or globally via the cluster setting `esql.query.allow_partial_results`.
15+
16+
notable: true

docs/release-notes/breaking-changes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ If you are migrating from a version prior to version 9.0, you must first upgrade
1212

1313
% ## Next version [elasticsearch-nextversion-breaking-changes]
1414

15+
## 9.1.0 [elasticsearch-910-breaking-changes]
16+
17+
ES|QL
18+
: * Allow partial results by default in ES|QL [#125060](https://github.com/elastic/elasticsearch/pull/125060)
19+
1520
## 9.0.0 [elasticsearch-900-breaking-changes]
1621

1722
Aggregations:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ static ElasticsearchCluster buildCluster() {
2121
.module("test-esql-heap-attack")
2222
.setting("xpack.security.enabled", "false")
2323
.setting("xpack.license.self_generated.type", "trial")
24+
.setting("esql.query.allow_partial_results", "false")
2425
.jvmArg("-Xmx512m");
2526
String javaVersion = JvmInfo.jvmInfo().version();
2627
if (javaVersion.equals("20") || javaVersion.equals("21")) {

x-pack/plugin/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ tasks.named("yamlRestCompatTestTransform").configure({ task ->
125125
task.replaceValueInMatch("Size", 49, "Test flamegraph from profiling-events")
126126
task.replaceValueInMatch("Size", 49, "Test flamegraph from test-events")
127127
task.skipTest("esql/90_non_indexed/fetch", "Temporary until backported")
128+
task.skipTest("esql/63_enrich_int_range/Invalid age as double", "TODO: require disable allow_partial_results")
128129
})
129130

130131
tasks.named('yamlRestCompatTest').configure {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ private RestClient remoteClusterClient() throws IOException {
8383

8484
@Before
8585
public void skipTestOnOldVersions() {
86-
assumeTrue("skip on old versions", Clusters.localClusterVersion().equals(Version.V_8_16_0));
86+
assumeTrue("skip on old versions", Clusters.localClusterVersion().equals(Version.V_8_19_0));
8787
}
8888
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.junit.rules.TestRule;
2929

3030
import java.io.IOException;
31+
import java.util.List;
3132
import java.util.Map;
3233

3334
import static org.elasticsearch.test.MapMatcher.assertMap;
@@ -87,6 +88,12 @@ protected String from(String... indexName) {
8788

8889
@Override
8990
public Map<String, Object> runEsql(RestEsqlTestCase.RequestObjectBuilder requestObject) throws IOException {
91+
if (requestObject.allowPartialResults() != null) {
92+
assumeTrue(
93+
"require allow_partial_results on local cluster",
94+
clusterHasCapability("POST", "/_query", List.of(), List.of("support_partial_results")).orElse(false)
95+
);
96+
}
9097
requestObject.includeCCSMetadata(true);
9198
return super.runEsql(requestObject);
9299
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void testInvalidPragma() throws IOException {
111111
request.setJsonEntity("{\"f\":" + i + "}");
112112
assertOK(client().performRequest(request));
113113
}
114-
RequestObjectBuilder builder = requestObjectBuilder().query("from test-index | limit 1 | keep f");
114+
RequestObjectBuilder builder = requestObjectBuilder().query("from test-index | limit 1 | keep f").allowPartialResults(false);
115115
builder.pragmas(Settings.builder().put("data_partitioning", "invalid-option").build());
116116
ResponseException re = expectThrows(ResponseException.class, () -> runEsqlSync(builder));
117117
assertThat(EntityUtils.toString(re.getResponse().getEntity()), containsString("No enum constant"));

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public static class RequestObjectBuilder {
131131
private Boolean includeCCSMetadata = null;
132132

133133
private CheckedConsumer<XContentBuilder, IOException> filter;
134-
private Boolean allPartialResults = null;
134+
private Boolean allowPartialResults = null;
135135

136136
public RequestObjectBuilder() throws IOException {
137137
this(randomFrom(XContentType.values()));
@@ -209,11 +209,15 @@ public RequestObjectBuilder filter(CheckedConsumer<XContentBuilder, IOException>
209209
return this;
210210
}
211211

212-
public RequestObjectBuilder allPartialResults(boolean allPartialResults) {
213-
this.allPartialResults = allPartialResults;
212+
public RequestObjectBuilder allowPartialResults(boolean allowPartialResults) {
213+
this.allowPartialResults = allowPartialResults;
214214
return this;
215215
}
216216

217+
public Boolean allowPartialResults() {
218+
return allowPartialResults;
219+
}
220+
217221
public RequestObjectBuilder build() throws IOException {
218222
if (isBuilt == false) {
219223
if (tables != null) {
@@ -1376,8 +1380,8 @@ protected static Request prepareRequestWithOptions(RequestObjectBuilder requestO
13761380
requestObject.build();
13771381
Request request = prepareRequest(mode);
13781382
String mediaType = attachBody(requestObject, request);
1379-
if (requestObject.allPartialResults != null) {
1380-
request.addParameter("allow_partial_results", String.valueOf(requestObject.allPartialResults));
1383+
if (requestObject.allowPartialResults != null) {
1384+
request.addParameter("allow_partial_results", String.valueOf(requestObject.allowPartialResults));
13811385
}
13821386

13831387
RequestOptions.Builder options = request.getOptions().toBuilder();

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

Lines changed: 6 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

@@ -76,6 +77,11 @@ protected Collection<Class<? extends Plugin>> nodePlugins(String clusterAlias) {
7677
return plugins;
7778
}
7879

80+
@Override
81+
protected Settings nodeSettings() {
82+
return Settings.builder().put(super.nodeSettings()).put(EsqlPlugin.QUERY_ALLOW_PARTIAL_RESULTS.getKey(), false).build();
83+
}
84+
7985
public static class InternalExchangePlugin extends Plugin {
8086
@Override
8187
public List<Setting<?>> getSettings() {

0 commit comments

Comments
 (0)