Skip to content

Commit fcf476c

Browse files
committed
Revert "ESQL: Revert "Allow partial results by default in ES|QL (elastic#125060)" (elastic#126286)"
This reverts commit 8f38b13. Restore changes from elastic#125060 now that the breakage should be fixed.
1 parent 0f6b0b9 commit fcf476c

File tree

19 files changed

+100
-60
lines changed

19 files changed

+100
-60
lines changed

docs/changelog/125060.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pr: 125060
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/changelog/126286.yaml

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

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/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlSecurityIT.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,10 @@ public void testIndexPatternErrorMessageComparison_ESQL_SearchDSL() throws Excep
315315
setUser(searchRequest, "metadata1_read2");
316316

317317
// ES|QL query on the same index pattern
318-
var esqlResp = expectThrows(ResponseException.class, () -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2"));
318+
var esqlResp = expectThrows(
319+
ResponseException.class,
320+
() -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2", false)
321+
);
319322
var srchResp = expectThrows(ResponseException.class, () -> client().performRequest(searchRequest));
320323

321324
for (ResponseException r : List.of(esqlResp, srchResp)) {
@@ -334,7 +337,8 @@ public void testLimitedPrivilege() throws Exception {
334337
ResponseException.class,
335338
() -> runESQLCommand(
336339
"metadata1_read2",
337-
"FROM index-user1,index-user2 METADATA _index | STATS sum=sum(value), index=VALUES(_index)"
340+
"FROM index-user1,index-user2 METADATA _index | STATS sum=sum(value), index=VALUES(_index)",
341+
false
338342
)
339343
);
340344
assertThat(
@@ -347,7 +351,7 @@ public void testLimitedPrivilege() throws Exception {
347351

348352
resp = expectThrows(
349353
ResponseException.class,
350-
() -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2 METADATA _index | STATS index=VALUES(_index)")
354+
() -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2 METADATA _index | STATS index=VALUES(_index)", false)
351355
);
352356
assertThat(
353357
EntityUtils.toString(resp.getResponse().getEntity()),
@@ -359,7 +363,7 @@ public void testLimitedPrivilege() throws Exception {
359363

360364
resp = expectThrows(
361365
ResponseException.class,
362-
() -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2 | STATS sum=sum(value)")
366+
() -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2 | STATS sum=sum(value)", false)
363367
);
364368
assertThat(
365369
EntityUtils.toString(resp.getResponse().getEntity()),
@@ -371,7 +375,7 @@ public void testLimitedPrivilege() throws Exception {
371375

372376
resp = expectThrows(
373377
ResponseException.class,
374-
() -> runESQLCommand("alias_user1", "FROM first-alias,index-user1 METADATA _index | KEEP _index, org, value | LIMIT 10")
378+
() -> runESQLCommand("alias_user1", "FROM first-alias,index-user1 METADATA _index | KEEP _index, org, value | LIMIT 10", false)
375379
);
376380
assertThat(
377381
EntityUtils.toString(resp.getResponse().getEntity()),
@@ -385,7 +389,8 @@ public void testLimitedPrivilege() throws Exception {
385389
ResponseException.class,
386390
() -> runESQLCommand(
387391
"alias_user2",
388-
"from second-alias,index-user2 METADATA _index | stats sum=sum(value), index=VALUES(_index)"
392+
"from second-alias,index-user2 METADATA _index | stats sum=sum(value), index=VALUES(_index)",
393+
false
389394
)
390395
);
391396
assertThat(
@@ -859,6 +864,10 @@ public void testDataStream() throws IOException {
859864
}
860865

861866
protected Response runESQLCommand(String user, String command) throws IOException {
867+
return runESQLCommand(user, command, null);
868+
}
869+
870+
protected Response runESQLCommand(String user, String command, Boolean allowPartialResults) throws IOException {
862871
if (command.toLowerCase(Locale.ROOT).contains("limit") == false) {
863872
// add a (high) limit to avoid warnings on default limit
864873
command += " | limit 10000000";
@@ -872,6 +881,9 @@ protected Response runESQLCommand(String user, String command) throws IOExceptio
872881
request.setJsonEntity(Strings.toString(json));
873882
setUser(request, user);
874883
request.addParameter("error_trace", "true");
884+
if (allowPartialResults != null) {
885+
request.addParameter("allow_partial_results", Boolean.toString(allowPartialResults));
886+
}
875887
return client().performRequest(request);
876888
}
877889

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/EsqlRestValidationTestCase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ private Request createRequest(String indexName) throws IOException {
129129
final var request = new Request("POST", "/_query");
130130
request.addParameter("error_trace", "true");
131131
request.addParameter("pretty", "true");
132+
request.addParameter("allow_partial_results", Boolean.toString(false));
132133
request.setJsonEntity(
133134
Strings.toString(JsonXContent.contentBuilder().startObject().field("query", "from " + indexName).endObject())
134135
);

0 commit comments

Comments
 (0)