Skip to content

Commit 9d8f7e1

Browse files
committed
Allow partial results by default in ES|QL
1 parent b563145 commit 9d8f7e1

File tree

6 files changed

+41
-43
lines changed

6 files changed

+41
-43
lines changed

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
@@ -312,7 +312,10 @@ public void testIndexPatternErrorMessageComparison_ESQL_SearchDSL() throws Excep
312312
searchRequest.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("es-security-runas-user", "metadata1_read2"));
313313

314314
// ES|QL query on the same index pattern
315-
var esqlResp = expectThrows(ResponseException.class, () -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2"));
315+
var esqlResp = expectThrows(
316+
ResponseException.class,
317+
() -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2", false)
318+
);
316319
var srchResp = expectThrows(ResponseException.class, () -> client().performRequest(searchRequest));
317320

318321
for (ResponseException r : List.of(esqlResp, srchResp)) {
@@ -331,7 +334,8 @@ public void testLimitedPrivilege() throws Exception {
331334
ResponseException.class,
332335
() -> runESQLCommand(
333336
"metadata1_read2",
334-
"FROM index-user1,index-user2 METADATA _index | STATS sum=sum(value), index=VALUES(_index)"
337+
"FROM index-user1,index-user2 METADATA _index | STATS sum=sum(value), index=VALUES(_index)",
338+
false
335339
)
336340
);
337341
assertThat(
@@ -344,7 +348,7 @@ public void testLimitedPrivilege() throws Exception {
344348

345349
resp = expectThrows(
346350
ResponseException.class,
347-
() -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2 METADATA _index | STATS index=VALUES(_index)")
351+
() -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2 METADATA _index | STATS index=VALUES(_index)", false)
348352
);
349353
assertThat(
350354
EntityUtils.toString(resp.getResponse().getEntity()),
@@ -356,7 +360,7 @@ public void testLimitedPrivilege() throws Exception {
356360

357361
resp = expectThrows(
358362
ResponseException.class,
359-
() -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2 | STATS sum=sum(value)")
363+
() -> runESQLCommand("metadata1_read2", "FROM index-user1,index-user2 | STATS sum=sum(value)", false)
360364
);
361365
assertThat(
362366
EntityUtils.toString(resp.getResponse().getEntity()),
@@ -368,7 +372,7 @@ public void testLimitedPrivilege() throws Exception {
368372

369373
resp = expectThrows(
370374
ResponseException.class,
371-
() -> runESQLCommand("alias_user1", "FROM first-alias,index-user1 METADATA _index | KEEP _index, org, value | LIMIT 10")
375+
() -> runESQLCommand("alias_user1", "FROM first-alias,index-user1 METADATA _index | KEEP _index, org, value | LIMIT 10", false)
372376
);
373377
assertThat(
374378
EntityUtils.toString(resp.getResponse().getEntity()),
@@ -382,7 +386,8 @@ public void testLimitedPrivilege() throws Exception {
382386
ResponseException.class,
383387
() -> runESQLCommand(
384388
"alias_user2",
385-
"from second-alias,index-user2 METADATA _index | stats sum=sum(value), index=VALUES(_index)"
389+
"from second-alias,index-user2 METADATA _index | stats sum=sum(value), index=VALUES(_index)",
390+
false
386391
)
387392
);
388393
assertThat(
@@ -826,6 +831,10 @@ public void testDataStream() throws IOException {
826831
}
827832

828833
protected Response runESQLCommand(String user, String command) throws IOException {
834+
return runESQLCommand(user, command, null);
835+
}
836+
837+
protected Response runESQLCommand(String user, String command, Boolean allowPartialResults) throws IOException {
829838
if (command.toLowerCase(Locale.ROOT).contains("limit") == false) {
830839
// add a (high) limit to avoid warnings on default limit
831840
command += " | limit 10000000";
@@ -839,6 +848,9 @@ protected Response runESQLCommand(String user, String command) throws IOExceptio
839848
request.setJsonEntity(Strings.toString(json));
840849
request.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("es-security-runas-user", user));
841850
request.addParameter("error_trace", "true");
851+
if (allowPartialResults != null) {
852+
request.addParameter("allow_partial_results", Boolean.toString(allowPartialResults));
853+
}
842854
return client().performRequest(request);
843855
}
844856

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() {

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

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,20 @@
1414
import org.elasticsearch.action.index.IndexRequest;
1515
import org.elasticsearch.action.support.PlainActionFuture;
1616
import org.elasticsearch.action.support.WriteRequest;
17-
import org.elasticsearch.common.settings.Setting;
17+
import org.elasticsearch.common.settings.Settings;
1818
import org.elasticsearch.common.transport.TransportAddress;
1919
import org.elasticsearch.compute.operator.DriverTaskRunner;
2020
import org.elasticsearch.compute.operator.exchange.ExchangeService;
2121
import org.elasticsearch.core.TimeValue;
22-
import org.elasticsearch.plugins.Plugin;
2322
import org.elasticsearch.tasks.TaskCancelledException;
2423
import org.elasticsearch.tasks.TaskInfo;
25-
import org.elasticsearch.test.AbstractMultiClustersTestCase;
2624
import org.elasticsearch.transport.TransportService;
2725
import org.elasticsearch.xcontent.XContentBuilder;
2826
import org.elasticsearch.xcontent.json.JsonXContent;
2927
import org.elasticsearch.xpack.esql.EsqlTestUtils;
3028
import org.elasticsearch.xpack.esql.plugin.ComputeService;
31-
import org.junit.After;
32-
import org.junit.Before;
3329

3430
import java.util.ArrayList;
35-
import java.util.Collection;
3631
import java.util.List;
3732
import java.util.concurrent.TimeUnit;
3833

@@ -44,7 +39,7 @@
4439
import static org.hamcrest.Matchers.hasSize;
4540
import static org.hamcrest.Matchers.instanceOf;
4641

47-
public class CrossClusterCancellationIT extends AbstractMultiClustersTestCase {
42+
public class CrossClusterCancellationIT extends AbstractCrossClusterTestCase {
4843
private static final String REMOTE_CLUSTER = "cluster-a";
4944

5045
@Override
@@ -53,35 +48,11 @@ protected List<String> remoteClusterAlias() {
5348
}
5449

5550
@Override
56-
protected Collection<Class<? extends Plugin>> nodePlugins(String clusterAlias) {
57-
List<Class<? extends Plugin>> plugins = new ArrayList<>(super.nodePlugins(clusterAlias));
58-
plugins.add(EsqlPluginWithEnterpriseOrTrialLicense.class);
59-
plugins.add(InternalExchangePlugin.class);
60-
plugins.add(SimplePauseFieldPlugin.class);
61-
return plugins;
62-
}
63-
64-
public static class InternalExchangePlugin extends Plugin {
65-
@Override
66-
public List<Setting<?>> getSettings() {
67-
return List.of(
68-
Setting.timeSetting(
69-
ExchangeService.INACTIVE_SINKS_INTERVAL_SETTING,
70-
TimeValue.timeValueMillis(between(3000, 4000)),
71-
Setting.Property.NodeScope
72-
)
73-
);
74-
}
75-
}
76-
77-
@Before
78-
public void resetPlugin() {
79-
SimplePauseFieldPlugin.resetPlugin();
80-
}
81-
82-
@After
83-
public void releasePlugin() {
84-
SimplePauseFieldPlugin.release();
51+
protected Settings nodeSettings() {
52+
return Settings.builder()
53+
.put(super.nodeSettings())
54+
.put(ExchangeService.INACTIVE_SINKS_INTERVAL_SETTING, TimeValue.timeValueMillis(between(3000, 4000)))
55+
.build();
8556
}
8657

8758
@Override

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
7171
@Override
7272
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
7373
return Settings.builder()
74+
.put(super.nodeSettings(nodeOrdinal, otherSettings))
7475
.put(ExchangeService.INACTIVE_SINKS_INTERVAL_SETTING, TimeValue.timeValueMillis(between(3000, 5000)))
7576
.build();
7677
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public class EsqlPlugin extends Plugin implements ActionPlugin {
105105

106106
public static final Setting<Boolean> QUERY_ALLOW_PARTIAL_RESULTS = Setting.boolSetting(
107107
"esql.query.allow_partial_results",
108-
false,
108+
true,
109109
Setting.Property.NodeScope,
110110
Setting.Property.Dynamic
111111
);

0 commit comments

Comments
 (0)