Skip to content
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

[8.11] ESQL: Add warning header when default LIMIT is applied (#100894) #101054

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/reference/esql/esql-rest.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ s|Description

|smile
|application/smile
|{wikipedia}/Smile_(data_interchange_format)[Smile] binary data format similar
|{wikipedia}/Smile_(data_interchange_format)[Smile] binary data format similar
to CBOR

|===
Expand Down Expand Up @@ -220,6 +220,7 @@ POST /_query
| WHERE page_count > 300 AND author == "Frank Herbert"
| STATS count = COUNT(*) by year
| WHERE count > 0
| LIMIT 5
"""
}
----
Expand All @@ -239,6 +240,7 @@ POST /_query
| WHERE page_count > ? AND author == ?
| STATS count = COUNT(*) by year
| WHERE count > ?
| LIMIT 5
""",
"params": [300, "Frank Herbert", 0]
}
Expand Down
12 changes: 6 additions & 6 deletions docs/reference/esql/multivalued-fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ POST /mv/_bulk?refresh

POST /_query
{
"query": "FROM mv"
"query": "FROM mv | LIMIT 2"
}
----

Expand Down Expand Up @@ -65,7 +65,7 @@ POST /mv/_bulk?refresh

POST /_query
{
"query": "FROM mv"
"query": "FROM mv | LIMIT 2"
}
----

Expand Down Expand Up @@ -106,7 +106,7 @@ POST /mv/_bulk?refresh

POST /_query
{
"query": "FROM mv"
"query": "FROM mv | LIMIT 2"
}
----

Expand Down Expand Up @@ -148,7 +148,7 @@ POST /mv/_bulk?refresh

POST /_query
{
"query": "FROM mv | EVAL b=TO_STRING(b)"
"query": "FROM mv | EVAL b=TO_STRING(b) | LIMIT 2"
}
----

Expand Down Expand Up @@ -183,7 +183,7 @@ POST /mv/_bulk?refresh

POST /_query
{
"query": "FROM mv | EVAL b + 2, a + b"
"query": "FROM mv | EVAL b + 2, a + b | LIMIT 4"
}
----

Expand Down Expand Up @@ -217,7 +217,7 @@ Work around this limitation by converting the field to single value with one of:
----
POST /_query
{
"query": "FROM mv | EVAL b=MV_MIN(b) | EVAL b + 2, a + b"
"query": "FROM mv | EVAL b=MV_MIN(b) | EVAL b + 2, a + b | LIMIT 4"
}
----
// TEST[continued]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -248,6 +249,10 @@ private void removeEnrichPolicy() throws Exception {
}

private Response runESQLCommand(String user, String command) throws IOException {
if (command.toLowerCase(Locale.ROOT).contains("limit") == false) {
// add a (high) limit to avoid warnings on default limit
command += " | limit 10000000";
}
Settings pragmas = Settings.EMPTY;
if (Build.current().isSnapshot()) {
Settings.Builder settings = Settings.builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.WarningsHandler;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.xcontent.XContentHelper;
Expand Down Expand Up @@ -277,6 +278,7 @@ private Response query(String query, String filterPath) throws IOException {
request.setOptions(
RequestOptions.DEFAULT.toBuilder()
.setRequestConfig(RequestConfig.custom().setSocketTimeout(Math.toIntExact(TimeValue.timeValueMinutes(5).millis())).build())
.setWarningsHandler(WarningsHandler.PERMISSIVE)
);
return client().performRequest(request);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ setup:
warnings:
- "Line 1:37: evaluation of [to_ip(coalesce(ip1.keyword, \"255.255.255.255\"))] failed, treating result as null. Only first 20 failures recorded."
- "Line 1:37: java.lang.IllegalArgumentException: '127.0' is not an IP string literal."
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'FROM test | sort emp_no | eval ip = to_ip(coalesce(ip1.keyword, "255.255.255.255")) | keep emp_no, ip'
Expand All @@ -36,6 +37,7 @@ setup:
warnings:
- "Line 1:98: evaluation of [to_ip(x2)] failed, treating result as null. Only first 20 failures recorded."
- "Line 1:98: java.lang.IllegalArgumentException: '127.00.1' is not an IP string literal."
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'FROM test | sort emp_no | eval x1 = concat(ip1, ip2), x2 = coalesce(x1, "255.255.255.255"), x3 = to_ip(x2) | keep emp_no, x*'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
setup:
- skip:
features: allowed_warnings_regex
- do:
indices.create:
index: test
Expand Down Expand Up @@ -109,6 +111,8 @@ setup:
---
"Test From":
- do:
allowed_warnings_regex:
- "No limit defined, adding default limit of \\[.*\\]"
esql.query:
body:
query: 'from test'
Expand Down Expand Up @@ -266,6 +270,8 @@ setup:
---
"Test Input Params":
- do:
allowed_warnings_regex:
- "No limit defined, adding default limit of \\[.*\\]"
esql.query:
body:
query: 'row a = ? | eval b = ?, c = 1 + ?'
Expand All @@ -283,6 +289,8 @@ setup:


- do:
allowed_warnings_regex:
- "No limit defined, adding default limit of \\[.*\\]"
esql.query:
body:
query: 'from test | where color == ? and count == ? and time == ? | keep data, count, color'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
setup:
- skip:
features: warnings
- do:
indices.create:
index: test
Expand Down Expand Up @@ -109,6 +111,8 @@ setup:
---
"Test From":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test'
Expand All @@ -130,6 +134,8 @@ setup:
---
"Test simple grouping avg":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | where color == "red" | stats avg(data) by color'
Expand All @@ -144,6 +150,8 @@ setup:
---
"Test From Stats Avg":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats avg(count)'
Expand All @@ -156,6 +164,8 @@ setup:
---
"Test From Stats Avg With Alias":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats f1 = avg(count)'
Expand All @@ -168,6 +178,8 @@ setup:
---
"Test From Stats Count":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats count(data)'
Expand All @@ -180,6 +192,8 @@ setup:
---
"Test From Stats Count With Alias":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats dataCount = count(data)'
Expand All @@ -192,6 +206,8 @@ setup:
---
"Test From Stats Min":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats min(count)'
Expand All @@ -204,6 +220,8 @@ setup:
---
"Test From Stats Min With Alias":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats minCount=min(count)'
Expand All @@ -216,6 +234,8 @@ setup:
---
"Test From Stats Max":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats max(count)'
Expand All @@ -228,6 +248,8 @@ setup:
---
"Test From Stats Max With Alias":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats maxCount=max(count)'
Expand Down Expand Up @@ -255,6 +277,8 @@ setup:
---
"Test Median On Long":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats med=median(count)'
Expand All @@ -267,6 +291,8 @@ setup:
---
"Test Median On Double":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats med=median(count_d)'
Expand All @@ -279,6 +305,8 @@ setup:
---
"Test Grouping Median On Long":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats med=median(count) by color | sort med'
Expand All @@ -294,6 +322,8 @@ setup:
---
"Test Grouping Median On Double":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats med=median(count_d) by color | sort med'
Expand All @@ -309,6 +339,8 @@ setup:
---
"Test Median Absolute Deviation On Long":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats med=median_absolute_deviation(count)'
Expand All @@ -321,6 +353,8 @@ setup:
---
"Test Median Absolute Deviation On Double":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats med=median_absolute_deviation(count_d)'
Expand All @@ -333,6 +367,8 @@ setup:
---
"Test Grouping Median Absolute Deviation On Long":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats med=median_absolute_deviation(count) by color | sort color'
Expand All @@ -348,6 +384,8 @@ setup:
---
"Test Grouping Median Absolute Deviation On Double":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats med=median_absolute_deviation(count_d) by color | sort color'
Expand All @@ -363,6 +401,8 @@ setup:
---
"Test From Stats Eval":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats avg_count = avg(count) | eval x = avg_count + 7'
Expand All @@ -374,6 +414,8 @@ setup:
---
"Test Stats Where":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | stats x = avg(count) | where x > 100'
Expand All @@ -396,6 +438,8 @@ setup:
---
"Test Eval Row With Null":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'row a = 1, b = 2, c = null | eval z = c + b + a'
Expand All @@ -419,6 +463,8 @@ setup:
---
"Test Eval With Null And Count":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'from test | eval nullsum = count_d + null | stats count(nullsum)'
Expand All @@ -433,6 +479,8 @@ setup:
---
"Test Eval With Multiple Expressions":
- do:
warnings:
- "No limit defined, adding default limit of [500]"
esql.query:
body:
query: 'row l=1, d=1.0, ln=1 + null, dn=1.0 + null | stats sum(l), sum(d), sum(ln), sum(dn)'
Expand Down
Loading