-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Introduce allow_partial_results setting in ES|QL #122890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+286
−7
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e8873ce
Add allow_partial_results cluster settings in ES|QL
dnhatn 644aab4
[CI] Auto commit changes from spotless
elasticsearchmachine 7e9aea5
Update docs/changelog/122890.yaml
dnhatn 8d921bf
Mute org.elasticsearch.entitlement.runtime.policy.FileAccessTreeTests…
elasticsearchmachine 5e4abe4
Remove duplicate exclusive paths (#124023)
prdoyle 8933544
Mute org.elasticsearch.multiproject.test.CoreWithMultipleProjectsClie…
elasticsearchmachine be972e8
Mute org.elasticsearch.smoketest.MlWithSecurityIT test {yaml=ml/3rd_p…
elasticsearchmachine bd9536f
Use MultiProjectPendingException more consistently (#123955)
ywangd 68f6e1c
Merge remote-tracking branch 'elastic/main' into default-partial-resu…
dnhatn 9fe5a6a
internal API
dnhatn ed57e42
single module
dnhatn f0cbd46
avoid mock
dnhatn c8e4c35
Merge remote-tracking branch 'elastic/main' into default-partial-resu…
dnhatn 7aa2ea6
avoid mock
dnhatn 7d8450a
Merge remote-tracking branch 'elastic/main' into default-partial-resu…
dnhatn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 122890 | ||
summary: Introduce `allow_partial_results` setting in ES|QL | ||
area: ES|QL | ||
type: enhancement | ||
issues: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
...s/error-query/src/javaRestTest/java/org/elasticsearch/test/esql/EsqlPartialResultsIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch.test.esql; | ||
|
||
import org.apache.http.util.EntityUtils; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
import org.elasticsearch.client.ResponseException; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.test.cluster.ElasticsearchCluster; | ||
import org.elasticsearch.test.cluster.local.distribution.DistributionType; | ||
import org.elasticsearch.test.rest.ESRestTestCase; | ||
import org.junit.ClassRule; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.lessThanOrEqualTo; | ||
|
||
public class EsqlPartialResultsIT extends ESRestTestCase { | ||
@ClassRule | ||
public static ElasticsearchCluster cluster = ElasticsearchCluster.local() | ||
.distribution(DistributionType.DEFAULT) | ||
.module("test-error-query") | ||
.setting("xpack.security.enabled", "false") | ||
.setting("xpack.license.self_generated.type", "trial") | ||
.setting("esql.query.allow_partial_results", "true") | ||
.build(); | ||
|
||
@Override | ||
protected String getTestRestCluster() { | ||
return cluster.getHttpAddresses(); | ||
} | ||
|
||
public Set<String> populateIndices() throws Exception { | ||
int nextId = 0; | ||
{ | ||
createIndex("failing-index", Settings.EMPTY, """ | ||
{ | ||
"runtime": { | ||
"fail_me": { | ||
"type": "long", | ||
"script": { | ||
"source": "", | ||
"lang": "failing_field" | ||
} | ||
} | ||
}, | ||
"properties": { | ||
"v": { | ||
"type": "long" | ||
} | ||
} | ||
} | ||
"""); | ||
int numDocs = between(1, 50); | ||
for (int i = 0; i < numDocs; i++) { | ||
String id = Integer.toString(nextId++); | ||
Request doc = new Request("PUT", "failing-index/_doc/" + id); | ||
doc.setJsonEntity("{\"v\": " + id + "}"); | ||
client().performRequest(doc); | ||
} | ||
|
||
} | ||
Set<String> okIds = new HashSet<>(); | ||
{ | ||
createIndex("ok-index", Settings.EMPTY, """ | ||
{ | ||
"properties": { | ||
"v": { | ||
"type": "long" | ||
} | ||
} | ||
} | ||
"""); | ||
int numDocs = between(1, 50); | ||
for (int i = 0; i < numDocs; i++) { | ||
String id = Integer.toString(nextId++); | ||
okIds.add(id); | ||
Request doc = new Request("PUT", "ok-index/_doc/" + id); | ||
doc.setJsonEntity("{\"v\": " + id + "}"); | ||
client().performRequest(doc); | ||
} | ||
} | ||
refresh(client(), "failing-index,ok-index"); | ||
return okIds; | ||
} | ||
|
||
public void testPartialResult() throws Exception { | ||
Set<String> okIds = populateIndices(); | ||
String query = """ | ||
{ | ||
"query": "FROM ok-index,failing-index | LIMIT 100 | KEEP fail_me,v" | ||
} | ||
"""; | ||
// allow_partial_results = true | ||
{ | ||
Request request = new Request("POST", "/_query"); | ||
request.setJsonEntity(query); | ||
if (randomBoolean()) { | ||
request.addParameter("allow_partial_results", "true"); | ||
} | ||
Response resp = client().performRequest(request); | ||
Map<String, Object> results = entityAsMap(resp); | ||
assertThat(results.get("is_partial"), equalTo(true)); | ||
List<?> columns = (List<?>) results.get("columns"); | ||
assertThat(columns, equalTo(List.of(Map.of("name", "fail_me", "type", "long"), Map.of("name", "v", "type", "long")))); | ||
List<?> values = (List<?>) results.get("values"); | ||
assertThat(values.size(), lessThanOrEqualTo(okIds.size())); | ||
} | ||
// allow_partial_results = false | ||
{ | ||
Request request = new Request("POST", "/_query"); | ||
request.setJsonEntity(""" | ||
{ | ||
"query": "FROM ok-index,failing-index | LIMIT 100" | ||
} | ||
"""); | ||
request.addParameter("allow_partial_results", "false"); | ||
var error = expectThrows(ResponseException.class, () -> client().performRequest(request)); | ||
Response resp = error.getResponse(); | ||
assertThat(resp.getStatusLine().getStatusCode(), equalTo(500)); | ||
assertThat(EntityUtils.toString(resp.getEntity()), containsString("Accessing failing field")); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.