diff --git a/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java b/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java index 4f43817b7b92c..8c8eb942f891b 100644 --- a/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java +++ b/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java @@ -56,12 +56,13 @@ * crash Elasticsearch. */ public class HeapAttackIT extends ESRestTestCase { - @ClassRule public static ElasticsearchCluster cluster = Clusters.buildCluster(); static volatile boolean SUITE_ABORTED = false; + private static String ESQL_VERSION = "2024.04.01"; + @Override protected String getTestRestCluster() { return cluster.getHttpAddresses(); @@ -155,8 +156,8 @@ private Response groupOnManyLongs(int count) throws IOException { } private StringBuilder makeManyLongs(int count) { - StringBuilder query = new StringBuilder(); - query.append("{\"query\":\"FROM manylongs\\n| EVAL i0 = a + b, i1 = b + i0"); + StringBuilder query = startQueryWithVersion(ESQL_VERSION); + query.append("FROM manylongs\\n| EVAL i0 = a + b, i1 = b + i0"); for (int i = 2; i < count; i++) { query.append(", i").append(i).append(" = i").append(i - 2).append(" + ").append(i - 1); } @@ -186,8 +187,8 @@ public void testHugeConcat() throws IOException { } private Response concat(int evals) throws IOException { - StringBuilder query = new StringBuilder(); - query.append("{\"query\":\"FROM single | EVAL str = TO_STRING(a)"); + StringBuilder query = startQueryWithVersion(ESQL_VERSION); + query.append("FROM single | EVAL str = TO_STRING(a)"); for (int e = 0; e < evals; e++) { query.append("\n| EVAL str=CONCAT(") .append(IntStream.range(0, 10).mapToObj(i -> "str").collect(Collectors.joining(", "))) @@ -223,8 +224,8 @@ public void testHugeManyConcat() throws IOException { * Tests that generate many moderately long strings. */ private Response manyConcat(int strings) throws IOException { - StringBuilder query = new StringBuilder(); - query.append("{\"query\":\"FROM manylongs | EVAL str = CONCAT("); + StringBuilder query = startQueryWithVersion(ESQL_VERSION); + query.append("FROM manylongs | EVAL str = CONCAT("); query.append( Arrays.stream(new String[] { "a", "b", "c", "d", "e" }) .map(f -> "TO_STRING(" + f + ")") @@ -274,8 +275,8 @@ public void testTooManyEval() throws IOException { } private Response manyEval(int evalLines) throws IOException { - StringBuilder query = new StringBuilder(); - query.append("{\"query\":\"FROM manylongs"); + StringBuilder query = startQueryWithVersion(ESQL_VERSION); + query.append("FROM manylongs"); for (int e = 0; e < evalLines; e++) { query.append("\n| EVAL "); for (int i = 0; i < 10; i++) { @@ -356,7 +357,9 @@ public void testFetchTooManyBigFields() throws IOException { * Fetches documents containing 1000 fields which are {@code 1kb} each. */ private void fetchManyBigFields(int docs) throws IOException { - Response response = query("{\"query\": \"FROM manybigfields | SORT f000 | LIMIT " + docs + "\"}", "columns"); + StringBuilder query = startQueryWithVersion(ESQL_VERSION); + query.append("FROM manybigfields | SORT f000 | LIMIT " + docs + "\"}"); + Response response = query(query.toString(), "columns"); Map map = responseAsMap(response); ListMatcher columns = matchesList(); for (int f = 0; f < 1000; f++) { @@ -383,11 +386,12 @@ public void testAggTooManyMvLongs() throws IOException { } private Response aggMvLongs(int fields) throws IOException { - StringBuilder builder = new StringBuilder("{\"query\": \"FROM mv_longs | STATS MAX(f00) BY f00"); + StringBuilder query = startQueryWithVersion(ESQL_VERSION); + query.append("FROM mv_longs | STATS MAX(f00) BY f00"); for (int f = 1; f < fields; f++) { - builder.append(", f").append(String.format(Locale.ROOT, "%02d", f)); + query.append(", f").append(String.format(Locale.ROOT, "%02d", f)); } - return query(builder.append("\"}").toString(), "columns"); + return query(query.append("\"}").toString(), "columns"); } public void testFetchMvLongs() throws IOException { @@ -408,7 +412,9 @@ public void testFetchTooManyMvLongs() throws IOException { } private Response fetchMvLongs() throws IOException { - return query("{\"query\": \"FROM mv_longs\"}", "columns"); + StringBuilder query = startQueryWithVersion(ESQL_VERSION); + query.append("FROM mv_longs\"}"); + return query(query.toString(), "columns"); } private void initManyLongs() throws IOException { @@ -576,4 +582,12 @@ public void assertRequestBreakerEmpty() throws Exception { } }); } + + private static StringBuilder startQueryWithVersion(String version) { + StringBuilder query = new StringBuilder(); + query.append("{\"version\":\"" + version + "\","); + query.append("\"query\":\""); + + return query; + } } diff --git a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ImpersonateOfficialClientTestClient.java b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ImpersonateOfficialClientTestClient.java new file mode 100644 index 0000000000000..34856c8ca93cc --- /dev/null +++ b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ImpersonateOfficialClientTestClient.java @@ -0,0 +1,54 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.rest.yaml; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; +import org.elasticsearch.client.NodeSelector; +import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.RestClientBuilder; +import org.elasticsearch.common.CheckedSupplier; +import org.elasticsearch.test.rest.yaml.restspec.ClientYamlSuiteRestApi; +import org.elasticsearch.test.rest.yaml.restspec.ClientYamlSuiteRestSpec; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.function.BiPredicate; + +/** + * Impersonates an official test client by setting the @{code x-elastic-client-meta} header. + */ +public class ImpersonateOfficialClientTestClient extends ClientYamlTestClient { + private final String meta; + + public ImpersonateOfficialClientTestClient( + ClientYamlSuiteRestSpec restSpec, + RestClient restClient, + List hosts, + CheckedSupplier clientBuilderWithSniffedNodes, + String meta + ) { + super(restSpec, restClient, hosts, clientBuilderWithSniffedNodes); + this.meta = meta; + } + + @Override + public ClientYamlTestResponse callApi( + String apiName, + Map params, + HttpEntity entity, + Map headers, + NodeSelector nodeSelector, + BiPredicate pathPredicate + ) throws IOException { + headers.put("x-elastic-client-meta", meta); + return super.callApi(apiName, params, entity, headers, nodeSelector, pathPredicate); + } +} diff --git a/x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlAsyncSecurityIT.java b/x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlAsyncSecurityIT.java index 544eb82fb5ace..c7e9c3994ee4b 100644 --- a/x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlAsyncSecurityIT.java +++ b/x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlAsyncSecurityIT.java @@ -90,6 +90,7 @@ private Response runAsync(String user, String command) throws IOException { } XContentBuilder json = JsonXContent.contentBuilder(); json.startObject(); + json.field("version", ESQL_VERSION); json.field("query", command); addRandomPragmas(json); json.field("wait_for_completion_timeout", timeValueNanos(randomIntBetween(1, 1000))); diff --git a/x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlSecurityIT.java b/x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlSecurityIT.java index 7a9b90baa0d35..41df233af6459 100644 --- a/x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlSecurityIT.java +++ b/x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlSecurityIT.java @@ -38,6 +38,7 @@ import static org.hamcrest.Matchers.equalTo; public class EsqlSecurityIT extends ESRestTestCase { + static String ESQL_VERSION = "2024.04.01.🚀"; @ClassRule public static ElasticsearchCluster cluster = ElasticsearchCluster.local() @@ -354,6 +355,7 @@ protected Response runESQLCommand(String user, String command) throws IOExceptio } XContentBuilder json = JsonXContent.contentBuilder(); json.startObject(); + json.field("version", ESQL_VERSION); json.field("query", command); addRandomPragmas(json); json.endObject(); diff --git a/x-pack/plugin/esql/qa/server/mixed-cluster/build.gradle b/x-pack/plugin/esql/qa/server/mixed-cluster/build.gradle index 09397710bb856..c25ef858534e0 100644 --- a/x-pack/plugin/esql/qa/server/mixed-cluster/build.gradle +++ b/x-pack/plugin/esql/qa/server/mixed-cluster/build.gradle @@ -25,20 +25,27 @@ dependencies { GradleUtils.extendSourceSet(project, "javaRestTest", "yamlRestTest") +// ESQL is available in 8.11 or later def supportedVersion = bwcVersion -> { - // ESQL is available in 8.11 or later return bwcVersion.onOrAfter(Version.fromString("8.11.0")); } +// Versions on and after 8.13.3 will get a `version` parameter +def versionUnsupported = bwcVersion -> { + return bwcVersion.before(Version.fromString("8.13.3")); +} + BuildParams.bwcVersions.withWireCompatible(supportedVersion) { bwcVersion, baseName -> def javaRestTest = tasks.register("v${bwcVersion}#javaRestTest", StandaloneRestIntegTestTask) { usesBwcDistribution(bwcVersion) systemProperty("tests.old_cluster_version", bwcVersion) + systemProperty("tests.version_parameter_unsupported", versionUnsupported(bwcVersion)) } def yamlRestTest = tasks.register("v${bwcVersion}#yamlRestTest", StandaloneRestIntegTestTask) { usesBwcDistribution(bwcVersion) systemProperty("tests.old_cluster_version", bwcVersion) + systemProperty("tests.version_parameter_unsupported", versionUnsupported(bwcVersion)) testClassesDirs = sourceSets.yamlRestTest.output.classesDirs classpath = sourceSets.yamlRestTest.runtimeClasspath } diff --git a/x-pack/plugin/esql/qa/server/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/EsqlClientYamlIT.java b/x-pack/plugin/esql/qa/server/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/EsqlClientYamlIT.java index 2c9833ba0793e..9bb114aaa6f6c 100644 --- a/x-pack/plugin/esql/qa/server/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/EsqlClientYamlIT.java +++ b/x-pack/plugin/esql/qa/server/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/EsqlClientYamlIT.java @@ -9,14 +9,28 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import org.apache.http.HttpHost; +import org.elasticsearch.client.RestClient; import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; +import org.elasticsearch.test.rest.yaml.ClientYamlTestClient; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; +import org.elasticsearch.test.rest.yaml.ImpersonateOfficialClientTestClient; +import org.elasticsearch.test.rest.yaml.restspec.ClientYamlSuiteRestSpec; +import org.elasticsearch.test.rest.yaml.section.ApiCallSection; +import org.elasticsearch.test.rest.yaml.section.ClientYamlTestSection; +import org.elasticsearch.test.rest.yaml.section.DoSection; +import org.elasticsearch.test.rest.yaml.section.ExecutableSection; import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase; import org.junit.After; import org.junit.Before; import org.junit.ClassRule; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + public class EsqlClientYamlIT extends ESClientYamlSuiteTestCase { @ClassRule public static ElasticsearchCluster cluster = Clusters.mixedVersionCluster(); @@ -32,6 +46,9 @@ public EsqlClientYamlIT(final ClientYamlTestCandidate testCandidate) { @ParametersFactory public static Iterable parameters() throws Exception { + if (EsqlSpecTestCase.availableVersions().isEmpty()) { + return updateEsqlQueryDoSections(createParameters(), EsqlClientYamlIT::stripVersion); + } return createParameters(); } @@ -40,4 +57,63 @@ public static Iterable parameters() throws Exception { public void assertRequestBreakerEmpty() throws Exception { EsqlSpecTestCase.assertRequestBreakerEmpty(); } + + @Override + protected ClientYamlTestClient initClientYamlTestClient( + final ClientYamlSuiteRestSpec restSpec, + final RestClient restClient, + final List hosts + ) { + if (EsqlSpecTestCase.availableVersions().isEmpty()) { + return new ImpersonateOfficialClientTestClient(restSpec, restClient, hosts, this::getClientBuilderWithSniffedHosts, "es=8.13"); + } + return super.initClientYamlTestClient(restSpec, restClient, hosts); + } + + static DoSection stripVersion(DoSection doSection) { + ApiCallSection copy = doSection.getApiCallSection().copyWithNewApi(doSection.getApiCallSection().getApi()); + for (Map body : copy.getBodies()) { + body.remove("version"); + } + doSection.setApiCallSection(copy); + return doSection; + } + + // TODO: refactor, copied from single-node's AbstractEsqlClientYamlIt + public static Iterable updateEsqlQueryDoSections(Iterable parameters, Function modify) + throws Exception { + List result = new ArrayList<>(); + for (Object[] orig : parameters) { + assert orig.length == 1; + ClientYamlTestCandidate candidate = (ClientYamlTestCandidate) orig[0]; + try { + ClientYamlTestSection modified = new ClientYamlTestSection( + candidate.getTestSection().getLocation(), + candidate.getTestSection().getName(), + candidate.getTestSection().getPrerequisiteSection(), + candidate.getTestSection().getExecutableSections().stream().map(e -> modifyExecutableSection(e, modify)).toList() + ); + result.add(new Object[] { new ClientYamlTestCandidate(candidate.getRestTestSuite(), modified) }); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("error modifying " + candidate + ": " + e.getMessage(), e); + } + } + return result; + } + + // TODO: refactor, copied from single-node's AbstractEsqlClientYamlIt + private static ExecutableSection modifyExecutableSection(ExecutableSection e, Function modify) { + if (false == (e instanceof DoSection)) { + return e; + } + DoSection doSection = (DoSection) e; + String api = doSection.getApiCallSection().getApi(); + return switch (api) { + case "esql.query" -> modify.apply(doSection); + // case "esql.async_query", "esql.async_query_get" -> throw new IllegalArgumentException( + // "The esql yaml tests can't contain async_query or async_query_get because we modify them on the fly and *add* those." + // ); + default -> e; + }; + } } diff --git a/x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClustersIT.java b/x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClustersIT.java index 2f681fc23bf31..3a3fbdba74ae8 100644 --- a/x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClustersIT.java +++ b/x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClustersIT.java @@ -18,6 +18,7 @@ import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.TestFeatureService; +import org.elasticsearch.xpack.esql.EsqlTestUtils; import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase; import org.junit.After; import org.junit.Before; @@ -122,7 +123,9 @@ void indexDocs(RestClient client, String index, List docs) throws IOExcepti } private Map run(String query) throws IOException { - Map resp = runEsql(new RestEsqlTestCase.RequestObjectBuilder().query(query).build()); + Map resp = runEsql( + new RestEsqlTestCase.RequestObjectBuilder().query(query).version(EsqlTestUtils.latestEsqlVersionOrSnapshot()).build() + ); logger.info("--> query {} response {}", query, resp); return resp; } diff --git a/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/RestEsqlIT.java b/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/RestEsqlIT.java index 6743657e86874..4de2a0f565c71 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/RestEsqlIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/RestEsqlIT.java @@ -69,7 +69,7 @@ public void testBasicEsql() throws IOException { Response response = client().performRequest(bulk); Assert.assertEquals("{\"errors\":false}", EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8)); - RequestObjectBuilder builder = new RequestObjectBuilder().query(fromIndex() + " | stats avg(value)"); + RequestObjectBuilder builder = requestObjectBuilder().query(fromIndex() + " | stats avg(value)"); if (Build.current().isSnapshot()) { builder.pragmas(Settings.builder().put("data_partitioning", "shard").build()); } @@ -89,7 +89,7 @@ public void testInvalidPragma() throws IOException { request.setJsonEntity("{\"f\":" + i + "}"); assertOK(client().performRequest(request)); } - RequestObjectBuilder builder = new RequestObjectBuilder().query("from test-index | limit 1 | keep f"); + RequestObjectBuilder builder = requestObjectBuilder().query("from test-index | limit 1 | keep f"); builder.pragmas(Settings.builder().put("data_partitioning", "invalid-option").build()); ResponseException re = expectThrows(ResponseException.class, () -> runEsqlSync(builder)); assertThat(EntityUtils.toString(re.getResponse().getEntity()), containsString("No enum constant")); @@ -99,7 +99,7 @@ public void testInvalidPragma() throws IOException { public void testPragmaNotAllowed() throws IOException { assumeFalse("pragma only disabled on release builds", Build.current().isSnapshot()); - RequestObjectBuilder builder = new RequestObjectBuilder().query("row a = 1, b = 2"); + RequestObjectBuilder builder = requestObjectBuilder().query("row a = 1, b = 2"); builder.pragmas(Settings.builder().put("data_partitioning", "shard").build()); ResponseException re = expectThrows(ResponseException.class, () -> runEsqlSync(builder)); assertThat(EntityUtils.toString(re.getResponse().getEntity()), containsString("[pragma] only allowed in snapshot builds")); @@ -197,7 +197,7 @@ public void testIncompatibleMappingsErrors() throws IOException { } private void assertException(String query, String... errorMessages) throws IOException { - ResponseException re = expectThrows(ResponseException.class, () -> runEsqlSync(new RequestObjectBuilder().query(query))); + ResponseException re = expectThrows(ResponseException.class, () -> runEsqlSync(requestObjectBuilder().query(query))); assertThat(re.getResponse().getStatusLine().getStatusCode(), equalTo(400)); for (var error : errorMessages) { assertThat(re.getMessage(), containsString(error)); diff --git a/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/TSDBRestEsqlIT.java b/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/TSDBRestEsqlIT.java index b7ab7b623d460..057119103f0e9 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/TSDBRestEsqlIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/TSDBRestEsqlIT.java @@ -61,9 +61,8 @@ public void testTimeSeriesQuerying() throws IOException { Response response = client().performRequest(bulk); assertEquals("{\"errors\":false}", EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8)); - RestEsqlTestCase.RequestObjectBuilder builder = new RestEsqlTestCase.RequestObjectBuilder().query( - "FROM k8s | KEEP k8s.pod.name, @timestamp" - ); + RestEsqlTestCase.RequestObjectBuilder builder = RestEsqlTestCase.requestObjectBuilder() + .query("FROM k8s | KEEP k8s.pod.name, @timestamp"); builder.pragmas(Settings.builder().put("time_series", true).build()); Map result = runEsqlSync(builder); @SuppressWarnings("unchecked") diff --git a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/AbstractEsqlClientYamlIT.java b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/AbstractEsqlClientYamlIT.java index 70afdf32d3808..b2a3b12c2a027 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/AbstractEsqlClientYamlIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/AbstractEsqlClientYamlIT.java @@ -11,13 +11,19 @@ import org.elasticsearch.test.cluster.local.distribution.DistributionType; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; +import org.elasticsearch.test.rest.yaml.section.ClientYamlTestSection; +import org.elasticsearch.test.rest.yaml.section.DoSection; +import org.elasticsearch.test.rest.yaml.section.ExecutableSection; import org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase; import org.junit.After; import org.junit.Before; import org.junit.ClassRule; -abstract class AbstractEsqlClientYamlIT extends ESClientYamlSuiteTestCase { +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; +abstract class AbstractEsqlClientYamlIT extends ESClientYamlSuiteTestCase { @ClassRule public static ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) @@ -44,4 +50,40 @@ private void assertRequestBreakerEmpty() throws Exception { */ EsqlSpecTestCase.assertRequestBreakerEmpty(); } + + public static Iterable updateEsqlQueryDoSections(Iterable parameters, Function modify) + throws Exception { + List result = new ArrayList<>(); + for (Object[] orig : parameters) { + assert orig.length == 1; + ClientYamlTestCandidate candidate = (ClientYamlTestCandidate) orig[0]; + try { + ClientYamlTestSection modified = new ClientYamlTestSection( + candidate.getTestSection().getLocation(), + candidate.getTestSection().getName(), + candidate.getTestSection().getPrerequisiteSection(), + candidate.getTestSection().getExecutableSections().stream().map(e -> modifyExecutableSection(e, modify)).toList() + ); + result.add(new Object[] { new ClientYamlTestCandidate(candidate.getRestTestSuite(), modified) }); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("error modifying " + candidate + ": " + e.getMessage(), e); + } + } + return result; + } + + private static ExecutableSection modifyExecutableSection(ExecutableSection e, Function modify) { + if (false == (e instanceof DoSection)) { + return e; + } + DoSection doSection = (DoSection) e; + String api = doSection.getApiCallSection().getApi(); + return switch (api) { + case "esql.query" -> modify.apply(doSection); + case "esql.async_query", "esql.async_query_get" -> throw new IllegalArgumentException( + "The esql yaml tests can't contain async_query or async_query_get because we modify them on the fly and *add* those." + ); + default -> e; + }; + } } diff --git a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncIT.java b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncIT.java index 657f396b2857f..f5bd1efb106a3 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncIT.java @@ -10,16 +10,9 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; -import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; import org.elasticsearch.test.rest.yaml.section.ApiCallSection; -import org.elasticsearch.test.rest.yaml.section.ClientYamlTestSection; -import org.elasticsearch.test.rest.yaml.section.DoSection; -import org.elasticsearch.test.rest.yaml.section.ExecutableSection; -import java.util.ArrayList; -import java.util.List; import java.util.Map; -import java.util.function.Function; /** * Run the ESQL yaml tests against the async esql endpoint with a 30 minute {@code wait_until_completion_timeout}. @@ -33,7 +26,7 @@ public EsqlClientYamlAsyncIT(final ClientYamlTestCandidate testCandidate) { @ParametersFactory public static Iterable parameters() throws Exception { - return parameters(doSection -> { + return updateEsqlQueryDoSections(createParameters(), doSection -> { ApiCallSection copy = doSection.getApiCallSection().copyWithNewApi("esql.async_query"); for (Map body : copy.getBodies()) { body.put("wait_for_completion_timeout", "30m"); @@ -42,39 +35,4 @@ public static Iterable parameters() throws Exception { return doSection; }); } - - public static Iterable parameters(Function modify) throws Exception { - List result = new ArrayList<>(); - for (Object[] orig : ESClientYamlSuiteTestCase.createParameters()) { - assert orig.length == 1; - ClientYamlTestCandidate candidate = (ClientYamlTestCandidate) orig[0]; - try { - ClientYamlTestSection modified = new ClientYamlTestSection( - candidate.getTestSection().getLocation(), - candidate.getTestSection().getName(), - candidate.getTestSection().getPrerequisiteSection(), - candidate.getTestSection().getExecutableSections().stream().map(e -> modifyExecutableSection(e, modify)).toList() - ); - result.add(new Object[] { new ClientYamlTestCandidate(candidate.getRestTestSuite(), modified) }); - } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("error modifying " + candidate + ": " + e.getMessage(), e); - } - } - return result; - } - - private static ExecutableSection modifyExecutableSection(ExecutableSection e, Function modify) { - if (false == (e instanceof DoSection)) { - return e; - } - DoSection doSection = (DoSection) e; - String api = doSection.getApiCallSection().getApi(); - return switch (api) { - case "esql.query" -> modify.apply(doSection); - case "esql.async_query", "esql.async_query_get" -> throw new IllegalArgumentException( - "The esql yaml tests can't contain async_query or async_query_get because we modify them on the fly and *add* those." - ); - default -> e; - }; - } } diff --git a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncSubmitAndFetchIT.java b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncSubmitAndFetchIT.java index b32a7385d12c5..38051007568e9 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncSubmitAndFetchIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/yamlRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlClientYamlAsyncSubmitAndFetchIT.java @@ -32,7 +32,7 @@ public EsqlClientYamlAsyncSubmitAndFetchIT(final ClientYamlTestCandidate testCan @ParametersFactory public static Iterable parameters() throws Exception { - return EsqlClientYamlAsyncIT.parameters(DoEsqlAsync::new); + return updateEsqlQueryDoSections(createParameters(), DoEsqlAsync::new); } private static class DoEsqlAsync implements ExecutableSection { diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java index 75723ed1d5313..14579dfb537da 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java @@ -68,7 +68,14 @@ public abstract class EsqlSpecTestCase extends ESRestTestCase { private final Integer lineNumber; protected final CsvTestCase testCase; protected final Mode mode; - protected final Set versions; + + public static Set availableVersions() { + if ("true".equals(System.getProperty("tests.version_parameter_unsupported"))) { + // TODO: skip tests with explicitly set version and/or strip the version if it's 2024.04.01. + return Set.of(); + } + return Build.current().isSnapshot() ? Set.of(EsqlVersion.values()) : Set.of(EsqlVersion.releasedAscending()); + } public enum Mode { SYNC, @@ -101,8 +108,6 @@ protected EsqlSpecTestCase(String fileName, String groupName, String testName, I this.lineNumber = lineNumber; this.testCase = testCase; this.mode = mode; - // TODO: Read applicable versions from csv-spec files/make it part of testCase. - this.versions = Build.current().isSnapshot() ? Set.of(EsqlVersion.values()) : Set.of(EsqlVersion.releasedAscending()); } @Before @@ -150,8 +155,13 @@ protected void shouldSkipTest(String testName) throws IOException { protected final void doTest() throws Throwable { RequestObjectBuilder builder = new RequestObjectBuilder(randomFrom(XContentType.values())); - EsqlVersion version = randomFrom(versions); - String versionString = randomBoolean() ? version.toString() : version.versionStringWithoutEmoji(); + + String versionString = null; + if (availableVersions().isEmpty() == false) { + EsqlVersion version = randomFrom(availableVersions()); + versionString = randomBoolean() ? version.toString() : version.versionStringWithoutEmoji(); + } + Map answer = runEsql( builder.query(testCase.query).version(versionString), testCase.expectedWarnings(false), diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/FieldExtractorTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/FieldExtractorTestCase.java index d107f8a147fd6..d5daab2d46a80 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/FieldExtractorTestCase.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/FieldExtractorTestCase.java @@ -26,6 +26,7 @@ import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xcontent.json.JsonXContent; +import org.elasticsearch.xpack.esql.EsqlTestUtils; import org.hamcrest.Matcher; import org.junit.Before; @@ -296,7 +297,7 @@ public void testFlattenedUnsupported() throws IOException { new Test("flattened").createIndex("test", "flattened"); index("test", """ {"flattened": {"a": "foo"}}"""); - Map result = runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | LIMIT 2")); + Map result = runEsql("FROM test* | LIMIT 2"); assertMap( result, @@ -310,10 +311,7 @@ public void testEmptyMapping() throws IOException { index("test", """ {}"""); - ResponseException e = expectThrows( - ResponseException.class, - () -> runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | SORT missing | LIMIT 3")) - ); + ResponseException e = expectThrows(ResponseException.class, () -> runEsql("FROM test* | SORT missing | LIMIT 3")); String err = EntityUtils.toString(e.getResponse().getEntity()); assertThat(err, containsString("Unknown column [missing]")); @@ -674,16 +672,13 @@ public void testIncompatibleTypes() throws IOException { index("test2", """ {"f": 1}"""); - Map result = runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test*")); + Map result = runEsql("FROM test*"); assertMap( result, matchesMap().entry("columns", List.of(columnInfo("f", "unsupported"))) .entry("values", List.of(matchesList().item(null), matchesList().item(null))) ); - ResponseException e = expectThrows( - ResponseException.class, - () -> runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | SORT f | LIMIT 3")) - ); + ResponseException e = expectThrows(ResponseException.class, () -> runEsql("FROM test* | SORT f | LIMIT 3")); String err = EntityUtils.toString(e.getResponse().getEntity()); assertThat( deyaml(err), @@ -715,7 +710,7 @@ public void testDistinctInEachIndex() throws IOException { index("test2", """ {"other": "o2"}"""); - Map result = runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | SORT file, other")); + Map result = runEsql("FROM test* | SORT file, other"); assertMap( result, matchesMap().entry("columns", List.of(columnInfo("file", "keyword"), columnInfo("other", "keyword"))) @@ -769,10 +764,7 @@ public void testMergeKeywordAndObject() throws IOException { index("test2", """ {"file": {"raw": "o2"}}"""); - ResponseException e = expectThrows( - ResponseException.class, - () -> runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | SORT file, file.raw | LIMIT 3")) - ); + ResponseException e = expectThrows(ResponseException.class, () -> runEsql("FROM test* | SORT file, file.raw | LIMIT 3")); String err = EntityUtils.toString(e.getResponse().getEntity()); assertThat( deyaml(err), @@ -782,7 +774,7 @@ public void testMergeKeywordAndObject() throws IOException { ) ); - Map result = runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | SORT file.raw | LIMIT 2")); + Map result = runEsql("FROM test* | SORT file.raw | LIMIT 2"); assertMap( result, matchesMap().entry("columns", List.of(columnInfo("file", "unsupported"), columnInfo("file.raw", "keyword"))) @@ -822,15 +814,12 @@ public void testPropagateUnsupportedToSubFields() throws IOException { index("test", """ {"f": "192.168.0.1/24"}"""); - ResponseException e = expectThrows( - ResponseException.class, - () -> runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | SORT f, f.raw | LIMIT 3")) - ); + ResponseException e = expectThrows(ResponseException.class, () -> runEsql("FROM test* | SORT f, f.raw | LIMIT 3")); String err = EntityUtils.toString(e.getResponse().getEntity()); assertThat(err, containsString("Cannot use field [f] with unsupported type [ip_range]")); assertThat(err, containsString("Cannot use field [f.raw] with unsupported type [ip_range]")); - Map result = runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | LIMIT 2")); + Map result = runEsql("FROM test* | LIMIT 2"); assertMap( result, matchesMap().entry("columns", List.of(columnInfo("f", "unsupported"), columnInfo("f.raw", "unsupported"))) @@ -888,15 +877,12 @@ public void testMergeUnsupportedAndObject() throws IOException { index("test2", """ {"f": {"raw": "o2"}}"""); - ResponseException e = expectThrows( - ResponseException.class, - () -> runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | SORT f, f.raw | LIMIT 3")) - ); + ResponseException e = expectThrows(ResponseException.class, () -> runEsql("FROM test* | SORT f, f.raw | LIMIT 3")); String err = EntityUtils.toString(e.getResponse().getEntity()); assertThat(err, containsString("Cannot use field [f] with unsupported type [ip_range]")); assertThat(err, containsString("Cannot use field [f.raw] with unsupported type [ip_range]")); - Map result = runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | LIMIT 2")); + Map result = runEsql("FROM test* | LIMIT 2"); assertMap( result, matchesMap().entry("columns", List.of(columnInfo("f", "unsupported"), columnInfo("f.raw", "unsupported"))) @@ -931,7 +917,7 @@ public void testIntegerDocValuesConflict() throws IOException { index("test2", """ {"emp_no": 2}"""); - Map result = runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | SORT emp_no | LIMIT 2")); + Map result = runEsql("FROM test* | SORT emp_no | LIMIT 2"); assertMap( result, matchesMap().entry("columns", List.of(columnInfo("emp_no", "integer"))) @@ -967,10 +953,7 @@ public void testLongIntegerConflict() throws IOException { index("test2", """ {"emp_no": 2}"""); - ResponseException e = expectThrows( - ResponseException.class, - () -> runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | SORT emp_no | LIMIT 3")) - ); + ResponseException e = expectThrows(ResponseException.class, () -> runEsql("FROM test* | SORT emp_no | LIMIT 3")); String err = EntityUtils.toString(e.getResponse().getEntity()); assertThat( deyaml(err), @@ -980,7 +963,7 @@ public void testLongIntegerConflict() throws IOException { ) ); - Map result = runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | LIMIT 2")); + Map result = runEsql("FROM test* | LIMIT 2"); assertMap( result, matchesMap().entry("columns", List.of(columnInfo("emp_no", "unsupported"))) @@ -1016,10 +999,7 @@ public void testIntegerShortConflict() throws IOException { index("test2", """ {"emp_no": 2}"""); - ResponseException e = expectThrows( - ResponseException.class, - () -> runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | SORT emp_no | LIMIT 3")) - ); + ResponseException e = expectThrows(ResponseException.class, () -> runEsql("FROM test* | SORT emp_no | LIMIT 3")); String err = EntityUtils.toString(e.getResponse().getEntity()); assertThat( deyaml(err), @@ -1029,7 +1009,7 @@ public void testIntegerShortConflict() throws IOException { ) ); - Map result = runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | LIMIT 2")); + Map result = runEsql("FROM test* | LIMIT 2"); assertMap( result, matchesMap().entry("columns", List.of(columnInfo("emp_no", "unsupported"))) @@ -1071,13 +1051,10 @@ public void testTypeConflictInObject() throws IOException { index("test2", """ {"foo": {"emp_no": "cat"}}"""); - Map result = runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | LIMIT 3")); + Map result = runEsql("FROM test* | LIMIT 3"); assertMap(result, matchesMap().entry("columns", List.of(columnInfo("foo.emp_no", "unsupported"))).extraOk()); - ResponseException e = expectThrows( - ResponseException.class, - () -> runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | SORT foo.emp_no | LIMIT 3")) - ); + ResponseException e = expectThrows(ResponseException.class, () -> runEsql("FROM test* | SORT foo.emp_no | LIMIT 3")); String err = EntityUtils.toString(e.getResponse().getEntity()); assertThat( deyaml(err), @@ -1413,7 +1390,7 @@ private void fieldMapping(XContentBuilder builder) throws IOException { } private Map fetchAll() throws IOException { - return runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | LIMIT 10")); + return runEsql("FROM test* | LIMIT 10"); } } @@ -1456,4 +1433,9 @@ private static void createIndex(String name, CheckedConsumer runEsql(String query) throws IOException { + return runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query(query).version(EsqlTestUtils.latestEsqlVersionOrSnapshot())); + } + } diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEnrichTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEnrichTestCase.java index a670b11c61780..07abc26e8c789 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEnrichTestCase.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEnrichTestCase.java @@ -13,6 +13,7 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.ResponseException; import org.elasticsearch.test.rest.ESRestTestCase; +import org.elasticsearch.xpack.esql.EsqlTestUtils; import org.junit.After; import org.junit.Before; @@ -142,10 +143,7 @@ public void wipeTestData() throws IOException { } public void testNonExistentEnrichPolicy() throws IOException { - ResponseException re = expectThrows( - ResponseException.class, - () -> RestEsqlTestCase.runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("from test | enrich countris")) - ); + ResponseException re = expectThrows(ResponseException.class, () -> runEsql("from test | enrich countris", Mode.SYNC)); assertThat( EntityUtils.toString(re.getResponse().getEntity()), containsString("cannot find enrich policy [countris], did you mean [countries]?") @@ -153,12 +151,7 @@ public void testNonExistentEnrichPolicy() throws IOException { } public void testNonExistentEnrichPolicy_KeepField() throws IOException { - ResponseException re = expectThrows( - ResponseException.class, - () -> RestEsqlTestCase.runEsqlSync( - new RestEsqlTestCase.RequestObjectBuilder().query("from test | enrich countris | keep number") - ) - ); + ResponseException re = expectThrows(ResponseException.class, () -> runEsql("from test | enrich countris | keep number", Mode.SYNC)); assertThat( EntityUtils.toString(re.getResponse().getEntity()), containsString("cannot find enrich policy [countris], did you mean [countries]?") @@ -166,9 +159,7 @@ public void testNonExistentEnrichPolicy_KeepField() throws IOException { } public void testMatchField_ImplicitFieldsList() throws IOException { - Map result = runEsql( - new RestEsqlTestCase.RequestObjectBuilder().query("from test | enrich countries | keep number | sort number") - ); + Map result = runEsql("from test | enrich countries | keep number | sort number"); var columns = List.of(Map.of("name", "number", "type", "long")); var values = List.of(List.of(1000), List.of(1000), List.of(5000)); @@ -176,17 +167,19 @@ public void testMatchField_ImplicitFieldsList() throws IOException { } public void testMatchField_ImplicitFieldsList_WithStats() throws IOException { - Map result = runEsql( - new RestEsqlTestCase.RequestObjectBuilder().query("from test | enrich countries | stats s = sum(number) by country_name") - - ); + Map result = runEsql("from test | enrich countries | stats s = sum(number) by country_name"); var columns = List.of(Map.of("name", "s", "type", "long"), Map.of("name", "country_name", "type", "keyword")); var values = List.of(List.of(2000, "United States of America"), List.of(5000, "China")); assertMap(result, matchesMap().entry("columns", columns).entry("values", values)); } - private Map runEsql(RestEsqlTestCase.RequestObjectBuilder requestObject) throws IOException { + private Map runEsql(String query) throws IOException { + return runEsql(query, mode); + } + + private Map runEsql(String query, Mode mode) throws IOException { + var requestObject = new RestEsqlTestCase.RequestObjectBuilder().query(query).version(EsqlTestUtils.latestEsqlVersionOrSnapshot()); if (mode == Mode.ASYNC) { return RestEsqlTestCase.runEsqlAsync(requestObject); } else { diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java index 86d48aca3baed..76fbbcfb71d79 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java @@ -113,6 +113,7 @@ protected RestEsqlTestCase(Mode mode) { public static class RequestObjectBuilder { private final XContentBuilder builder; private boolean isBuilt = false; + private String version; private Boolean keepOnCompletion = null; @@ -131,7 +132,7 @@ public RequestObjectBuilder query(String query) throws IOException { } public RequestObjectBuilder version(String version) throws IOException { - builder.field("version", version); + this.version = version; return this; } @@ -179,6 +180,9 @@ public RequestObjectBuilder pragmas(Settings pragmas) throws IOException { public RequestObjectBuilder build() throws IOException { if (isBuilt == false) { + if (version != null) { + builder.field("version", version); + } builder.endObject(); isBuilt = true; } @@ -203,7 +207,7 @@ public static RequestObjectBuilder jsonBuilder() throws IOException { } public void testGetAnswer() throws IOException { - Map answer = runEsql(builder().query("row a = 1, b = 2")); + Map answer = runEsql(requestObjectBuilder().query("row a = 1, b = 2")); assertEquals(2, answer.size()); Map colA = Map.of("name", "a", "type", "integer"); Map colB = Map.of("name", "b", "type", "integer"); @@ -212,7 +216,7 @@ public void testGetAnswer() throws IOException { } public void testUseUnknownIndex() throws IOException { - ResponseException e = expectThrows(ResponseException.class, () -> runEsql(builder().query("from doesNotExist"))); + ResponseException e = expectThrows(ResponseException.class, () -> runEsql(requestObjectBuilder().query("from doesNotExist"))); assertEquals(400, e.getResponse().getStatusLine().getStatusCode()); assertThat(e.getMessage(), containsString("verification_exception")); assertThat(e.getMessage(), containsString("Unknown index [doesNotExist]")); @@ -236,7 +240,7 @@ private void useKnownIndexWithOther(String other, String option) throws IOExcept String q = fromIndex() + ',' + other; q += " OPTIONS \"" + option + "\"=\"" + o + "\""; q += " | KEEP keyword, integer | SORT integer asc | LIMIT 10"; - return builder().query(q); + return requestObjectBuilder().query(q); }; // test failure @@ -258,7 +262,7 @@ private void useUnknownIndex(String option) { CheckedFunction builder = o -> { String q = "FROM doesnotexist OPTIONS \"" + option + "\"=\"" + o + "\""; q += " | KEEP keyword, integer | SORT integer asc | LIMIT 10"; - return builder().query(q); + return requestObjectBuilder().query(q); }; // test failure 404 from resolver @@ -285,7 +289,7 @@ public void testSearchPreference() throws IOException { q += " OPTIONS " + o; } q += " | KEEP keyword, integer | SORT integer asc | LIMIT 10"; - return builder().query(q); + return requestObjectBuilder().query(q); }; // verify that it returns as expected @@ -319,14 +323,14 @@ public void testNullInAggs() throws IOException { Response response = client().performRequest(bulk); assertThat(EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8), equalTo("{\"errors\":false}")); - RequestObjectBuilder builder = new RequestObjectBuilder().query(fromIndex() + " | stats min(value)"); + RequestObjectBuilder builder = requestObjectBuilder().query(fromIndex() + " | stats min(value)"); Map result = runEsql(builder); assertMap( result, matchesMap().entry("values", List.of(List.of(1))).entry("columns", List.of(Map.of("name", "min(value)", "type", "long"))) ); - builder = new RequestObjectBuilder().query(fromIndex() + " | stats min(value) by group | sort group, `min(value)`"); + builder = requestObjectBuilder().query(fromIndex() + " | stats min(value) by group | sort group, `min(value)`"); result = runEsql(builder); assertMap( result, @@ -340,7 +344,7 @@ public void testColumnarMode() throws IOException { bulkLoadTestData(docCount); boolean columnar = randomBoolean(); - var query = builder().query(fromIndex() + " | keep keyword, integer | sort integer asc"); + var query = requestObjectBuilder().query(fromIndex() + " | keep keyword, integer | sort integer asc"); if (columnar || randomBoolean()) { query.columnar(columnar); } @@ -370,27 +374,27 @@ public void testColumnarMode() throws IOException { public void testTextMode() throws IOException { int count = randomIntBetween(0, 100); bulkLoadTestData(count); - var builder = builder().query(fromIndex() + " | keep keyword, integer | sort integer asc | limit 100"); + var builder = requestObjectBuilder().query(fromIndex() + " | keep keyword, integer | sort integer asc | limit 100"); assertEquals(expectedTextBody("txt", count, null), runEsqlAsTextWithFormat(builder, "txt", null)); } public void testCSVMode() throws IOException { int count = randomIntBetween(0, 100); bulkLoadTestData(count); - var builder = builder().query(fromIndex() + " | keep keyword, integer | sort integer asc | limit 100"); + var builder = requestObjectBuilder().query(fromIndex() + " | keep keyword, integer | sort integer asc | limit 100"); assertEquals(expectedTextBody("csv", count, '|'), runEsqlAsTextWithFormat(builder, "csv", '|')); } public void testTSVMode() throws IOException { int count = randomIntBetween(0, 100); bulkLoadTestData(count); - var builder = builder().query(fromIndex() + " | keep keyword, integer | sort integer asc | limit 100"); + var builder = requestObjectBuilder().query(fromIndex() + " | keep keyword, integer | sort integer asc | limit 100"); assertEquals(expectedTextBody("tsv", count, null), runEsqlAsTextWithFormat(builder, "tsv", null)); } public void testCSVNoHeaderMode() throws IOException { bulkLoadTestData(1); - var builder = builder().query(fromIndex() + " | keep keyword, integer | sort integer asc | limit 100"); + var builder = requestObjectBuilder().query(fromIndex() + " | keep keyword, integer | sort integer asc | limit 100"); Request request = prepareRequest(SYNC); String mediaType = attachBody(builder.build(), request); RequestOptions.Builder options = request.getOptions().toBuilder(); @@ -448,7 +452,7 @@ public void testOutOfRangeComparisons() throws IOException { for (String fieldWithType : dataTypes) { for (String truePredicate : trueForSingleValuesPredicates) { String comparison = fieldWithType + truePredicate; - var query = builder().query(format(null, "from {} | where {}", testIndexName(), comparison)); + var query = requestObjectBuilder().query(format(null, "from {} | where {}", testIndexName(), comparison)); List expectedWarnings = List.of( "Line 1:29: evaluation of [" + comparison + "] failed, treating result as null. Only first 20 failures recorded.", "Line 1:29: java.lang.IllegalArgumentException: single-value function encountered multi-value" @@ -465,7 +469,7 @@ public void testOutOfRangeComparisons() throws IOException { for (String falsePredicate : alwaysFalsePredicates) { String comparison = fieldWithType + falsePredicate; - var query = builder().query(format(null, "from {} | where {}", testIndexName(), comparison)); + var query = requestObjectBuilder().query(format(null, "from {} | where {}", testIndexName(), comparison)); var result = runEsql(query); var values = as(result.get("values"), ArrayList.class); @@ -481,7 +485,7 @@ public void testWarningHeadersOnFailedConversions() throws IOException { Request request = prepareRequest(SYNC); var query = fromIndex() + " | sort integer asc | eval asInt = to_int(case(integer % 2 == 0, to_str(integer), keyword)) | limit 1000"; - var mediaType = attachBody(new RequestObjectBuilder().query(query).build(), request); + var mediaType = attachBody(requestObjectBuilder().query(query).build(), request); RequestOptions.Builder options = request.getOptions().toBuilder(); options.setWarningsHandler(WarningsHandler.PERMISSIVE); @@ -521,7 +525,7 @@ public void testMetadataFieldsOnMultipleIndices() throws IOException { assertEquals(201, client().performRequest(request).getStatusLine().getStatusCode()); var query = fromIndex() + "* metadata _index, _version, _id | sort _version"; - Map result = runEsql(new RequestObjectBuilder().query(query)); + Map result = runEsql(requestObjectBuilder().query(query)); var columns = List.of( Map.of("name", "a", "type", "long"), Map.of("name", "_index", "type", "keyword"), @@ -539,7 +543,7 @@ public void testMetadataFieldsOnMultipleIndices() throws IOException { public void testErrorMessageForEmptyParams() throws IOException { ResponseException re = expectThrows( ResponseException.class, - () -> runEsql(new RequestObjectBuilder().query("row a = 1 | eval x = ?").params("[]")) + () -> runEsql(requestObjectBuilder().query("row a = 1 | eval x = ?").params("[]")) ); assertThat(EntityUtils.toString(re.getResponse().getEntity()), containsString("Not enough actual parameters 0")); } @@ -547,7 +551,7 @@ public void testErrorMessageForEmptyParams() throws IOException { public void testErrorMessageForInvalidParams() throws IOException { ResponseException re = expectThrows( ResponseException.class, - () -> runEsql(new RequestObjectBuilder().query("row a = 1").params("[{\"x\":\"y\"}]")) + () -> runEsql(requestObjectBuilder().query("row a = 1").params("[{\"x\":\"y\"}]")) ); assertThat(EntityUtils.toString(re.getResponse().getEntity()), containsString("Required [value, type]")); } @@ -555,7 +559,7 @@ public void testErrorMessageForInvalidParams() throws IOException { public void testErrorMessageForMissingTypeInParams() throws IOException { ResponseException re = expectThrows( ResponseException.class, - () -> runEsql(new RequestObjectBuilder().query("row a = 1").params("[\"x\", 123, true, {\"value\": \"y\"}]")) + () -> runEsql(requestObjectBuilder().query("row a = 1").params("[\"x\", 123, true, {\"value\": \"y\"}]")) ); assertThat(EntityUtils.toString(re.getResponse().getEntity()), containsString("Required [type]")); } @@ -563,7 +567,7 @@ public void testErrorMessageForMissingTypeInParams() throws IOException { public void testErrorMessageForMissingValueInParams() throws IOException { ResponseException re = expectThrows( ResponseException.class, - () -> runEsql(new RequestObjectBuilder().query("row a = 1").params("[\"x\", 123, true, {\"type\": \"y\"}]")) + () -> runEsql(requestObjectBuilder().query("row a = 1").params("[\"x\", 123, true, {\"type\": \"y\"}]")) ); assertThat(EntityUtils.toString(re.getResponse().getEntity()), containsString("Required [value]")); } @@ -571,7 +575,7 @@ public void testErrorMessageForMissingValueInParams() throws IOException { public void testErrorMessageForInvalidTypeInParams() throws IOException { ResponseException re = expectThrows( ResponseException.class, - () -> runEsqlSync(new RequestObjectBuilder().query("row a = 1 | eval x = ?").params("[{\"type\": \"byte\", \"value\": 5}]")) + () -> runEsqlSync(requestObjectBuilder().query("row a = 1 | eval x = ?").params("[{\"type\": \"byte\", \"value\": 5}]")) ); assertThat( EntityUtils.toString(re.getResponse().getEntity()), @@ -608,7 +612,7 @@ public void testErrorMessageForLiteralDateMathOverflowOnNegation() throws IOExce private void assertExceptionForDateMath(String dateMathString, String errorSubstring) throws IOException { ResponseException re = expectThrows( ResponseException.class, - () -> runEsql(new RequestObjectBuilder().query("row a = 1 | eval x = now() + (" + dateMathString + ")")) + () -> runEsql(requestObjectBuilder().query("row a = 1 | eval x = now() + (" + dateMathString + ")")) ); String responseMessage = EntityUtils.toString(re.getResponse().getEntity()); @@ -621,9 +625,7 @@ private void assertExceptionForDateMath(String dateMathString, String errorSubst public void testErrorMessageForArrayValuesInParams() throws IOException { ResponseException re = expectThrows( ResponseException.class, - () -> runEsql( - new RequestObjectBuilder().query("row a = 1 | eval x = ?").params("[{\"type\": \"integer\", \"value\": [5, 6, 7]}]") - ) + () -> runEsql(requestObjectBuilder().query("row a = 1 | eval x = ?").params("[{\"type\": \"integer\", \"value\": [5, 6, 7]}]")) ); assertThat( EntityUtils.toString(re.getResponse().getEntity()), @@ -698,6 +700,10 @@ public static Map runEsqlSync( RequestOptions.Builder options = request.getOptions().toBuilder(); options.setWarningsHandler(WarningsHandler.PERMISSIVE); // We assert the warnings ourselves options.addHeader("Content-Type", mediaType); + if ("true".equals(System.getProperty("tests.version_parameter_unsupported"))) { + // Masquerade as an old version of the official client, so we get the oldest version by default + options.addHeader("x-elastic-client-meta", "es=8.13"); + } if (randomBoolean()) { options.addHeader("Accept", mediaType); @@ -723,6 +729,10 @@ public static Map runEsqlAsync( RequestOptions.Builder options = request.getOptions().toBuilder(); options.setWarningsHandler(WarningsHandler.PERMISSIVE); // We assert the warnings ourselves options.addHeader("Content-Type", mediaType); + if ("true".equals(System.getProperty("tests.version_parameter_unsupported"))) { + // Masquerade as an old version of the official client, so we get the oldest version by default + options.addHeader("x-elastic-client-meta", "es=8.13"); + } if (randomBoolean()) { options.addHeader("Accept", mediaType); @@ -1005,8 +1015,12 @@ private static String repeatValueAsMV(Object value) { return "[" + value + ", " + value + "]"; } - private static RequestObjectBuilder builder() throws IOException { - return new RequestObjectBuilder(); + public static RequestObjectBuilder requestObjectBuilder(String version) throws IOException { + return new RequestObjectBuilder().version(version); + } + + public static RequestObjectBuilder requestObjectBuilder() throws IOException { + return requestObjectBuilder(EsqlTestUtils.latestEsqlVersionOrSnapshot()); } @After diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeRestTest.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeRestTest.java index cdec7752aef59..e562c1cfa72e6 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeRestTest.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeRestTest.java @@ -12,6 +12,7 @@ import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xpack.esql.CsvTestsDataLoader; import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase; +import org.elasticsearch.xpack.esql.version.EsqlVersion; import org.junit.AfterClass; import org.junit.Before; @@ -96,7 +97,9 @@ private void checkException(EsqlQueryGenerator.QueryExecuted query) { private EsqlQueryGenerator.QueryExecuted execute(String command, int depth) { try { - Map a = RestEsqlTestCase.runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query(command).build()); + Map a = RestEsqlTestCase.runEsqlSync( + new RestEsqlTestCase.RequestObjectBuilder().query(command).version(EsqlVersion.ROCKET.toString()).build() + ); List outputSchema = outputSchema(a); return new EsqlQueryGenerator.QueryExecuted(command, depth, outputSchema, null); } catch (Exception e) { diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java index e6470e0eb2d05..5113346baf0ac 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.esql; import org.apache.lucene.util.BytesRef; +import org.elasticsearch.Build; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.compute.data.BlockFactory; import org.elasticsearch.compute.data.BlockUtils; @@ -23,6 +24,7 @@ import org.elasticsearch.xpack.esql.stats.Metrics; import org.elasticsearch.xpack.esql.stats.SearchStats; import org.elasticsearch.xpack.esql.type.EsqlDataTypeRegistry; +import org.elasticsearch.xpack.esql.version.EsqlVersion; import org.elasticsearch.xpack.ql.expression.Attribute; import org.elasticsearch.xpack.ql.expression.Literal; import org.elasticsearch.xpack.ql.plan.logical.LogicalPlan; @@ -54,9 +56,12 @@ import static org.junit.Assert.assertTrue; public final class EsqlTestUtils { + public static String latestEsqlVersionOrSnapshot() { + EsqlVersion version = Build.current().isSnapshot() ? EsqlVersion.SNAPSHOT : EsqlVersion.latestReleased(); + return version.toString(); + } public static class TestSearchStats extends SearchStats { - public TestSearchStats() { super(emptyList()); } diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/AbstractEsqlIntegTestCase.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/AbstractEsqlIntegTestCase.java index a9238d202e5b5..04a752e79b2f4 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/AbstractEsqlIntegTestCase.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/AbstractEsqlIntegTestCase.java @@ -25,6 +25,7 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.junit.annotations.TestLogging; +import org.elasticsearch.xpack.esql.EsqlTestUtils; import org.elasticsearch.xpack.esql.plugin.EsqlPlugin; import org.elasticsearch.xpack.esql.plugin.QueryPragmas; import org.elasticsearch.xpack.esql.plugin.TransportEsqlQueryAction; @@ -39,6 +40,21 @@ @TestLogging(value = "org.elasticsearch.xpack.esql.session:DEBUG", reason = "to better understand planning") public abstract class AbstractEsqlIntegTestCase extends ESIntegTestCase { + public static EsqlQueryRequest asyncSyncRequestOnLatestVersion() { + EsqlQueryRequest request = EsqlQueryRequest.asyncEsqlQueryRequest(); + applyLatestVersion(request); + return request; + } + + public static EsqlQueryRequest syncRequestOnLatestVersion() { + EsqlQueryRequest request = EsqlQueryRequest.syncEsqlQueryRequest(); + applyLatestVersion(request); + return request; + } + + private static void applyLatestVersion(EsqlQueryRequest request) { + request.esqlVersion(EsqlTestUtils.latestEsqlVersionOrSnapshot()); + } @After public void ensureExchangesAreReleased() throws Exception { @@ -138,9 +154,18 @@ protected EsqlQueryResponse run(String esqlCommands, QueryPragmas pragmas) { } protected EsqlQueryResponse run(String esqlCommands, QueryPragmas pragmas, QueryBuilder filter) { - EsqlQueryRequest request = new EsqlQueryRequest(); + return run(esqlCommands, pragmas, filter, null); + } + + protected EsqlQueryResponse run(String esqlCommands, QueryPragmas pragmas, QueryBuilder filter, String version) { + EsqlQueryRequest request = syncRequestOnLatestVersion(); + if (version != null) { + request.esqlVersion(version); + } request.query(esqlCommands); - request.pragmas(pragmas); + if (pragmas != null) { + request.pragmas(pragmas); + } if (filter != null) { request.filter(filter); } diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersCancellationIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersCancellationIT.java index bc4708cc19c1f..736a20b367b71 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersCancellationIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersCancellationIT.java @@ -159,7 +159,7 @@ private void createRemoteIndex(int numDocs) throws Exception { public void testCancel() throws Exception { createRemoteIndex(between(10, 100)); - EsqlQueryRequest request = new EsqlQueryRequest(); + EsqlQueryRequest request = AbstractEsqlIntegTestCase.syncRequestOnLatestVersion(); request.query("FROM *:test | STATS total=sum(const) | LIMIT 1"); request.pragmas(randomPragmas()); PlainActionFuture requestFuture = new PlainActionFuture<>(); diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersEnrichIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersEnrichIT.java index 2b59e6dd1957d..77fc6987e07c3 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersEnrichIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersEnrichIT.java @@ -457,7 +457,7 @@ public void testEnrichCoordinatorThenEnrichRemote() { } protected EsqlQueryResponse runQuery(String query) { - EsqlQueryRequest request = new EsqlQueryRequest(); + EsqlQueryRequest request = AbstractEsqlIntegTestCase.syncRequestOnLatestVersion(); request.query(query); request.pragmas(AbstractEsqlIntegTestCase.randomPragmas()); if (randomBoolean()) { diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersQueryIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersQueryIT.java index ac2abf21a8f8c..9021a10562124 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersQueryIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersQueryIT.java @@ -156,7 +156,7 @@ public void testProfile() { waitForNoInitializingShards(client(REMOTE_CLUSTER), TimeValue.timeValueSeconds(30), "logs-2"); final int localOnlyProfiles; { - EsqlQueryRequest request = new EsqlQueryRequest(); + EsqlQueryRequest request = AbstractEsqlIntegTestCase.syncRequestOnLatestVersion(); request.query("FROM logs* | stats sum(v)"); request.pragmas(pragmas); request.profile(true); @@ -171,7 +171,7 @@ public void testProfile() { } final int remoteOnlyProfiles; { - EsqlQueryRequest request = new EsqlQueryRequest(); + EsqlQueryRequest request = AbstractEsqlIntegTestCase.syncRequestOnLatestVersion(); request.query("FROM *:logs* | stats sum(v)"); request.pragmas(pragmas); request.profile(true); @@ -186,7 +186,7 @@ public void testProfile() { } final int allProfiles; { - EsqlQueryRequest request = new EsqlQueryRequest(); + EsqlQueryRequest request = AbstractEsqlIntegTestCase.syncRequestOnLatestVersion(); request.query("FROM logs*,*:logs* | stats total = sum(v)"); request.pragmas(pragmas); request.profile(true); @@ -203,7 +203,7 @@ public void testProfile() { } public void testWarnings() throws Exception { - EsqlQueryRequest request = new EsqlQueryRequest(); + EsqlQueryRequest request = AbstractEsqlIntegTestCase.syncRequestOnLatestVersion(); request.query("FROM logs*,*:logs* | EVAL ip = to_ip(id) | STATS total = sum(v) by ip | LIMIT 10"); PlainActionFuture future = new PlainActionFuture<>(); InternalTestCluster cluster = cluster(LOCAL_CLUSTER); @@ -229,7 +229,7 @@ public void testWarnings() throws Exception { } protected EsqlQueryResponse runQuery(String query) { - EsqlQueryRequest request = new EsqlQueryRequest(); + EsqlQueryRequest request = AbstractEsqlIntegTestCase.syncRequestOnLatestVersion(); request.query(query); request.pragmas(AbstractEsqlIntegTestCase.randomPragmas()); return runQuery(request); diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EnrichIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EnrichIT.java index 9b3f61175c3f7..43c282e9361f9 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EnrichIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EnrichIT.java @@ -328,7 +328,7 @@ public void testTopN() { } public void testProfile() { - EsqlQueryRequest request = new EsqlQueryRequest(); + EsqlQueryRequest request = AbstractEsqlIntegTestCase.syncRequestOnLatestVersion(); request.pragmas(randomPragmas()); request.query("from listens* | sort timestamp DESC | limit 1 | " + enrichSongCommand() + " | KEEP timestamp, artist"); request.profile(true); diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionBreakerIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionBreakerIT.java index 85eb0c02625ad..f16f5808da89f 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionBreakerIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionBreakerIT.java @@ -130,7 +130,7 @@ public void testBreaker() { setRequestCircuitBreakerLimit(ByteSizeValue.ofBytes(between(256, 512))); try { final ElasticsearchException e = expectThrows(ElasticsearchException.class, () -> { - var request = new EsqlQueryRequest(); + var request = AbstractEsqlIntegTestCase.syncRequestOnLatestVersion(); request.query("from test_breaker | stats count_distinct(foo) by bar"); request.pragmas(randomPragmas()); try (var ignored = client().execute(EsqlQueryAction.INSTANCE, request).actionGet(2, TimeUnit.MINUTES)) { diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionTaskIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionTaskIT.java index 4524c4c889fac..82ab52ca5a1b0 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionTaskIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionTaskIT.java @@ -367,7 +367,7 @@ protected void doRun() throws Exception { try { scriptPermits.release(numberOfDocs()); // do not block Lucene operators Client client = client(coordinator); - EsqlQueryRequest request = new EsqlQueryRequest(); + EsqlQueryRequest request = AbstractEsqlIntegTestCase.syncRequestOnLatestVersion(); client().admin() .indices() .prepareUpdateSettings("test") diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlAsyncActionIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlAsyncActionIT.java index e2e635917ed1c..27edadb25ab26 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlAsyncActionIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlAsyncActionIT.java @@ -52,8 +52,11 @@ protected Collection> nodePlugins() { } @Override - protected EsqlQueryResponse run(String esqlCommands, QueryPragmas pragmas, QueryBuilder filter) { - EsqlQueryRequest request = EsqlQueryRequest.asyncEsqlQueryRequest(); + protected EsqlQueryResponse run(String esqlCommands, QueryPragmas pragmas, QueryBuilder filter, String version) { + EsqlQueryRequest request = AbstractEsqlIntegTestCase.asyncSyncRequestOnLatestVersion(); + if (version != null) { + request.esqlVersion(version); + } request.query(esqlCommands); request.pragmas(pragmas); // deliberately small timeout, to frequently trigger incomplete response diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/TimeBasedIndicesIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/TimeBasedIndicesIT.java index a1fbee17ef8ec..150d617bb4e29 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/TimeBasedIndicesIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/TimeBasedIndicesIT.java @@ -37,19 +37,17 @@ public void testFilter() { } bulk.get(); { - EsqlQueryRequest request = new EsqlQueryRequest(); - request.query("FROM test | limit 1000"); - request.filter(new RangeQueryBuilder("@timestamp").from(epoch - TimeValue.timeValueHours(3).millis()).to("now")); - try (var resp = run(request)) { + String query = "FROM test | limit 1000"; + var filter = new RangeQueryBuilder("@timestamp").from(epoch - TimeValue.timeValueHours(3).millis()).to("now"); + try (var resp = run(query, null, filter)) { List> values = getValuesList(resp); assertThat(values, hasSize(oldDocs)); } } { - EsqlQueryRequest request = new EsqlQueryRequest(); - request.query("FROM test | limit 1000"); - request.filter(new RangeQueryBuilder("@timestamp").from("now").to(epoch + TimeValue.timeValueHours(3).millis())); - try (var resp = run(request)) { + String query = "FROM test | limit 1000"; + var filter = new RangeQueryBuilder("@timestamp").from("now").to(epoch + TimeValue.timeValueHours(3).millis()); + try (var resp = run(query, null, filter)) { List> values = getValuesList(resp); assertThat(values, hasSize(newDocs)); } diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/WarningsIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/WarningsIT.java index 0f05add15da53..445ca0414ed88 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/WarningsIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/WarningsIT.java @@ -68,7 +68,7 @@ public void testCollectWarnings() throws Exception { DiscoveryNode coordinator = randomFrom(clusterService().state().nodes().stream().toList()); client().admin().indices().prepareRefresh("index-1", "index-2").get(); - EsqlQueryRequest request = new EsqlQueryRequest(); + EsqlQueryRequest request = AbstractEsqlIntegTestCase.syncRequestOnLatestVersion(); request.query("FROM index-* | EVAL ip = to_ip(host) | STATS s = COUNT(*) by ip | KEEP ip | LIMIT 100"); request.pragmas(randomPragmas()); CountDownLatch latch = new CountDownLatch(1); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequest.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequest.java index 54ae2f4c90fc1..32ff0cf7bc6aa 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequest.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequest.java @@ -69,9 +69,7 @@ public EsqlQueryRequest(StreamInput in) throws IOException { public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; if (Strings.hasText(esqlVersion) == false) { - // TODO: make this required - // "https://github.com/elastic/elasticsearch/issues/104890" - // validationException = addValidationError(invalidVersion("is required"), validationException); + validationException = addValidationError(invalidVersion("is required"), validationException); } else { EsqlVersion version = EsqlVersion.parse(esqlVersion); if (version == null) { diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequestBuilder.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequestBuilder.java index 511fbd9f1c275..9eeffbb35c10e 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequestBuilder.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequestBuilder.java @@ -7,11 +7,13 @@ package org.elasticsearch.xpack.esql.action; +import org.elasticsearch.Build; import org.elasticsearch.client.internal.ElasticsearchClient; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.xpack.core.esql.action.internal.SharedSecrets; import org.elasticsearch.xpack.esql.plugin.QueryPragmas; +import org.elasticsearch.xpack.esql.version.EsqlVersion; public class EsqlQueryRequestBuilder extends org.elasticsearch.xpack.core.esql.action.EsqlQueryRequestBuilder< EsqlQueryRequest, @@ -27,6 +29,8 @@ public static EsqlQueryRequestBuilder newSyncEsqlQueryRequestBuilder(Elasticsear private EsqlQueryRequestBuilder(ElasticsearchClient client, EsqlQueryRequest request) { super(client, EsqlQueryAction.INSTANCE, request); + EsqlVersion version = Build.current().isSnapshot() ? EsqlVersion.SNAPSHOT : EsqlVersion.latestReleased(); + esqlVersion(version.versionStringWithoutEmoji()); } @Override diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequestTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequestTests.java index 6ec1af033f86c..0c9bfa2054b11 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequestTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/action/EsqlQueryRequestTests.java @@ -238,7 +238,6 @@ public void testSnapshotVersionIsOnlyValidOnSnapshot() throws IOException { assertThat(request.validate().getMessage(), containsString(errorOnNonSnapshotBuilds)); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/104890") public void testMissingVersionIsNotValid() throws IOException { String missingVersion = randomBoolean() ? "" : ", \"version\": \"\""; String json = String.format(Locale.ROOT, """ diff --git a/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityEsqlIT.java b/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityEsqlIT.java index 2c393ea7ed1df..6522196eb76ac 100644 --- a/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityEsqlIT.java +++ b/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityEsqlIT.java @@ -690,6 +690,9 @@ protected Request esqlRequest(String command) throws IOException { body.endObject(); } } + // TODO: we should use the latest or a random version, even when new versions are released. + String version = Build.current().isSnapshot() ? "snapshot" : "2024.04.01"; + body.field("version", version); body.endObject(); Request request = new Request("POST", "_query"); request.setJsonEntity(org.elasticsearch.common.Strings.toString(body)); diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/100_bug_fix.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/100_bug_fix.yml index 412e23a768535..bc1bf5987a6d8 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/100_bug_fix.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/100_bug_fix.yml @@ -22,6 +22,7 @@ esql.query: body: query: 'FROM test | sort emp_no | eval ip = to_ip(coalesce(ip1.keyword, "255.255.255.255")) | keep emp_no, ip' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -41,6 +42,7 @@ 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*' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -109,6 +111,7 @@ esql.query: body: query: 'from index* metadata _index | limit 5 | sort _index desc' + version: 2024.04.01 - match: { columns.0.name: http.headers } - match: { columns.0.type: unsupported } - match: { columns.1.name: http.headers.location } @@ -171,6 +174,7 @@ esql.query: body: query: 'from npe_single_value* | stats x = avg(field1) | limit 10' + version: 2024.04.01 - match: { columns.0.name: x } - match: { columns.0.type: double } - length: { values: 1 } @@ -180,6 +184,7 @@ esql.query: body: query: 'from npe_single_value* | stats x = avg(field2) | limit 10' + version: 2024.04.01 - match: { columns.0.name: x } - match: { columns.0.type: double } - length: { values: 1 } @@ -189,6 +194,7 @@ esql.query: body: query: 'from npe_single_value* | stats x = avg(field3) | limit 10' + version: 2024.04.01 - match: { columns.0.name: x } - match: { columns.0.type: double } - length: { values: 1 } @@ -232,6 +238,7 @@ esql.query: body: query: 'from idx_with_date_ip_txt | where id == 1 | eval x = date_format(text, date), y = date_extract(text2, date), p = date_parse(text, "2024-03-14") | keep x, y, p | limit 1' + version: 2024.04.01 - match: { columns.0.name: x } - match: { columns.0.type: keyword } - match: { columns.1.name: y } @@ -245,6 +252,7 @@ esql.query: body: query: 'from idx_with_date_ip_txt | where id > 1 | eval x = cidr_match(ip, text) | sort id | keep id, x | limit 2' + version: 2024.04.01 - match: { columns.0.name: id } - match: { columns.0.type: long } - match: { columns.1.name: x } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/10_basic.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/10_basic.yml index 52d390e7b288b..da87251c35966 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/10_basic.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/10_basic.yml @@ -118,6 +118,7 @@ setup: esql.query: body: query: 'from test' + version: 2024.04.01 - match: {columns.0.name: "color"} - match: {columns.0.type: "keyword"} @@ -139,6 +140,7 @@ setup: esql.query: body: query: 'from test | sort count | limit 1' + version: 2024.04.01 - match: {columns.1.name: "count"} - match: {columns.1.type: "long"} @@ -151,6 +153,7 @@ setup: body: query: 'from test | keep data | sort data | limit 2' columnar: true + version: 2024.04.01 - match: {columns.0.name: "data"} - match: {columns.0.type: "long"} @@ -162,6 +165,7 @@ setup: esql.query: body: query: 'from test | eval x = count + 7 | sort x | limit 1' + version: 2024.04.01 - match: {columns.0.name: "color"} - match: {columns.1.name: "count"} @@ -179,6 +183,7 @@ setup: esql.query: body: query: 'from test | sort time | eval x = data + 1, y = data_d + count, z = x + y | keep data, x, y, z, time | limit 2' + version: 2024.04.01 - match: {columns.0.name: "data"} - match: {columns.0.type: "long"} @@ -209,6 +214,7 @@ setup: body: query: 'from test | sort time | limit 2 | keep count' columnar: true + version: 2024.04.01 - length: {columns: 1} - match: {columns.0.name: "count"} @@ -222,6 +228,7 @@ setup: body: query: 'from test | sort time desc | limit 2 | keep count' columnar: true + version: 2024.04.01 - length: {columns: 1} - match: {columns.0.name: "count"} @@ -235,6 +242,7 @@ setup: body: query: 'from test | sort time | limit 2 | keep count | eval x = count + 1' columnar: true + version: 2024.04.01 - length: {columns: 2} - match: {columns.0.name: "count"} @@ -252,6 +260,7 @@ setup: body: query: 'from test | sort time | limit 2 | keep count | eval x = count + 1 | keep x' columnar: true + version: 2024.04.01 - length: {columns: 1} - match: {columns.0.name: "x"} @@ -265,6 +274,7 @@ setup: esql.query: body: query: 'from test | limit 10 | sort time | limit 1' + version: 2024.04.01 - length: {columns: 6} - length: {values: 1} @@ -278,6 +288,7 @@ setup: body: query: 'row a = ? | eval b = ?, c = 1 + ?' params: ["foo", 15, 10] + version: 2024.04.01 - length: {columns: 3} - match: {columns.0.name: "a"} @@ -297,6 +308,7 @@ setup: body: query: 'from test | where color == ? and count == ? and time == ? | keep data, count, color' params: ["green", 44, 1674835275193] + version: 2024.04.01 - length: {columns: 3} - match: {columns.0.name: "data"} @@ -315,6 +327,7 @@ setup: body: query: 'from test | eval x = ?, y = ?, z = ?, t = ?, u = ?, v = ? | keep x, y, z, t, u, v | limit 3' params: [{"value": 1, "type": "keyword"}, {"value": 2, "type": "double"}, null, true, 123, {"value": 123, "type": "long"}] + version: 2024.04.01 - length: {columns: 6} - match: {columns.0.name: "x"} diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/110_all_null.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/110_all_null.yml index a18dbba1abfab..f6271ab02b816 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/110_all_null.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/110_all_null.yml @@ -122,6 +122,7 @@ row wise and keep null: body: query: 'FROM test | WHERE time <= 1674835275188 | SORT time ASC | LIMIT 2' columnar: false + version: 2024.04.01 - length: {columns: 8} - match: {columns.0.name: "always_null"} @@ -153,6 +154,7 @@ row wise and drop null: body: query: 'FROM test | WHERE time <= 1674835275188 | SORT time ASC | LIMIT 2' columnar: false + version: 2024.04.01 - length: {all_columns: 8} - match: {all_columns.0.name: "always_null"} @@ -196,6 +198,7 @@ columnar and keep null: body: query: 'FROM test | WHERE time <= 1674835275188 | SORT time ASC | LIMIT 2' columnar: true + version: 2024.04.01 - length: {columns: 8} - match: {columns.0.name: "always_null"} @@ -227,6 +230,7 @@ columnar and drop null: body: query: 'FROM test | WHERE time <= 1674835275188 | SORT time ASC | LIMIT 2' columnar: true + version: 2024.04.01 - length: {all_columns: 8} - match: {all_columns.0.name: "always_null"} diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/110_insensitive_equals.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/110_insensitive_equals.yml index b40564cdac1de..e505d11cbe137 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/110_insensitive_equals.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/110_insensitive_equals.yml @@ -47,6 +47,7 @@ setup: esql.query: body: query: 'FROM test | where keyword =~ keywordUpper | keep id, keyword, keywordUpper' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -66,6 +67,7 @@ setup: esql.query: body: query: 'FROM test | where text =~ textCamel | keep id, text, textCamel' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -86,6 +88,7 @@ setup: esql.query: body: query: 'FROM test | where keyword =~ text | keep id, keyword, text' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -106,6 +109,7 @@ setup: esql.query: body: query: 'FROM test | where keywordUpper =~ textCamel | keep id, keywordUpper, textCamel | sort id' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -127,6 +131,7 @@ setup: esql.query: body: query: 'FROM test | where keywordUpper =~ "fo*" | keep id, keywordUpper' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -141,6 +146,7 @@ setup: esql.query: body: query: 'FROM test | where wildcard =~ "foo*" | keep id, wildcard' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -156,6 +162,7 @@ setup: esql.query: body: query: 'FROM test | where wildcard =~ "fOo*" | keep id, wildcard' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -172,6 +179,7 @@ setup: esql.query: body: query: 'FROM test | where keywordUpper =~ "fo?" | keep id, keywordUpper' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -186,6 +194,7 @@ setup: esql.query: body: query: 'FROM test | where wildcard =~ "bar?" | keep id, wildcard' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -201,6 +210,7 @@ setup: esql.query: body: query: 'FROM test | where wildcard =~ "bAr?" | keep id, wildcard' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -219,6 +229,7 @@ setup: esql.query: body: query: 'FROM test | where text =~ "Fo*" | keep id, text | sort id' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -233,6 +244,7 @@ setup: esql.query: body: query: 'FROM test | where wildcardText =~ "fOo*" | keep id, wildcardText' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -248,6 +260,7 @@ setup: esql.query: body: query: 'FROM test | where wildcardText =~ "bAr?" | keep id, wildcardText' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -266,6 +279,7 @@ setup: esql.query: body: query: 'FROM test | where text =~ "fo\\*" | keep id, text' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -283,6 +297,7 @@ setup: esql.query: body: query: 'FROM test | where wildcard =~ wildcardText | keep id, wildcard, wildcardText | sort id' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } @@ -302,6 +317,7 @@ setup: esql.query: body: query: 'FROM test | where NOT wildcard =~ wildcardText | keep id, wildcard, wildcardText | sort id' + version: 2024.04.01 - match: { columns.0.name: "id" } - match: { columns.0.type: "long" } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/120_profile.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/120_profile.yml index 17034de677b8d..ec415cbfa12d9 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/120_profile.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/120_profile.yml @@ -130,6 +130,7 @@ avg 8.14 or after: query: 'FROM test | STATS AVG(data) | LIMIT 1' columnar: true profile: true + version: 2024.04.01 - match: {columns.0.name: "AVG(data)"} - match: {columns.0.type: "double"} diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/130_spatial.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/130_spatial.yml index 053d33ee9bf43..2274d5973087d 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/130_spatial.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/130_spatial.yml @@ -97,6 +97,7 @@ geo_point: esql.query: body: query: 'from geo_points | sort id' + version: 2024.04.01 - match: { columns.0.name: id } - match: { columns.0.type: integer } - match: { columns.1.name: location } @@ -114,6 +115,7 @@ geo_point unsortable: esql.query: body: query: 'from geo_points | sort location' + version: 2024.04.01 --- geo_point unsortable with limit: @@ -122,6 +124,7 @@ geo_point unsortable with limit: esql.query: body: query: 'from geo_points | LIMIT 10 | sort location' + version: 2024.04.01 --- geo_point unsortable with limit from row: @@ -130,6 +133,7 @@ geo_point unsortable with limit from row: esql.query: body: query: 'ROW wkt = ["POINT(42.9711 -14.7553)", "POINT(75.8093 22.7277)"] | MV_EXPAND wkt | EVAL pt = TO_GEOPOINT(wkt) | limit 5 | sort pt' + version: 2024.04.01 --- values unsupported for geo_point: @@ -138,6 +142,7 @@ values unsupported for geo_point: esql.query: body: query: 'FROM geo_points | STATS VALUES(location)' + version: 2024.04.01 --- cartesian_point: @@ -147,6 +152,7 @@ cartesian_point: esql.query: body: query: 'from cartesian_points | sort id' + version: 2024.04.01 - match: { columns.0.name: id } - match: { columns.0.type: integer } - match: { columns.1.name: location } @@ -164,6 +170,7 @@ cartesian_point unsortable: esql.query: body: query: 'from cartesian_points | sort location' + version: 2024.04.01 --- cartesian_point unsortable with limit: @@ -172,6 +179,7 @@ cartesian_point unsortable with limit: esql.query: body: query: 'from cartesian_points | LIMIT 10 | sort location' + version: 2024.04.01 --- cartesian_point unsortable with limit from row: @@ -180,6 +188,7 @@ cartesian_point unsortable with limit from row: esql.query: body: query: 'ROW wkt = ["POINT(4297.11 -1475.53)", "POINT(7580.93 2272.77)"] | MV_EXPAND wkt | EVAL pt = TO_CARTESIANPOINT(wkt) | limit 5 | sort pt' + version: 2024.04.01 --- geo_shape: @@ -189,6 +198,7 @@ geo_shape: esql.query: body: query: 'from geo_shapes | sort id' + version: 2024.04.01 - match: { columns.0.name: id } - match: { columns.0.type: integer } - match: { columns.1.name: shape } @@ -206,6 +216,7 @@ geo_shape unsortable: esql.query: body: query: 'from geo_shapes | sort shape' + version: 2024.04.01 --- geo_shape unsortable with limit: @@ -214,6 +225,7 @@ geo_shape unsortable with limit: esql.query: body: query: 'from geo_shapes | LIMIT 10 | sort shape' + version: 2024.04.01 --- geo_shape unsortable with limit from row: @@ -222,6 +234,7 @@ geo_shape unsortable with limit from row: esql.query: body: query: 'ROW wkt = ["POINT(42.9711 -14.7553)", "POINT(75.8093 22.7277)"] | MV_EXPAND wkt | EVAL shape = TO_GEOSHAPE(wkt) | limit 5 | sort shape' + version: 2024.04.01 --- cartesian_shape: @@ -231,6 +244,7 @@ cartesian_shape: esql.query: body: query: 'from cartesian_shapes | sort id' + version: 2024.04.01 - match: { columns.0.name: id } - match: { columns.0.type: integer } - match: { columns.1.name: shape } @@ -248,6 +262,7 @@ cartesian_shape unsortable: esql.query: body: query: 'from cartesian_shapes | sort shape' + version: 2024.04.01 --- cartesian_shape unsortable with limit: @@ -256,6 +271,7 @@ cartesian_shape unsortable with limit: esql.query: body: query: 'from cartesian_shapes | LIMIT 10 | sort shape' + version: 2024.04.01 --- cartesian_shape unsortable with limit from row: @@ -264,3 +280,4 @@ cartesian_shape unsortable with limit from row: esql.query: body: query: 'ROW wkt = ["POINT(4297.11 -1475.53)", "POINT(7580.93 2272.77)"] | MV_EXPAND wkt | EVAL shape = TO_CARTESIANSHAPE(wkt) | limit 5 | sort shape' + version: 2024.04.01 diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/20_aggs.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/20_aggs.yml index 672dfa1503c40..69a9213980f98 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/20_aggs.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/20_aggs.yml @@ -120,6 +120,7 @@ setup: esql.query: body: query: 'from test' + version: 2024.04.01 - match: {columns.0.name: "color"} - match: {columns.0.type: "keyword"} @@ -146,6 +147,7 @@ setup: body: query: 'from test | where color == "red" | stats avg(data) by color' columnar: true + version: 2024.04.01 - match: {columns.0.name: "avg(data)"} - match: {columns.0.type: "double"} @@ -162,6 +164,7 @@ setup: body: query: 'from test | stats avg(count)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "avg(count)"} - match: {columns.0.type: "double"} @@ -176,6 +179,7 @@ setup: body: query: 'from test | stats f1 = avg(count)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "f1"} - match: {columns.0.type: "double"} @@ -190,6 +194,7 @@ setup: body: query: 'from test | stats count(data)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "count(data)"} - match: {columns.0.type: "long"} @@ -204,6 +209,7 @@ setup: body: query: 'from test | stats dataCount = count(data)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "dataCount"} - match: {columns.0.type: "long"} @@ -218,6 +224,7 @@ setup: body: query: 'from test | stats min(count)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "min(count)"} - match: {columns.0.type: "long"} @@ -232,6 +239,7 @@ setup: body: query: 'from test | stats minCount=min(count)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "minCount"} - match: {columns.0.type: "long"} @@ -246,6 +254,7 @@ setup: body: query: 'from test | stats max(count)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "max(count)"} - match: {columns.0.type: "long"} @@ -260,6 +269,7 @@ setup: body: query: 'from test | stats maxCount=max(count)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "maxCount"} - match: {columns.0.type: "long"} @@ -272,6 +282,7 @@ setup: body: query: 'from test | stats avg(count) by color | sort color | limit 2' columnar: true + version: 2024.04.01 - match: {columns.0.name: "avg(count)"} - match: {columns.0.type: "double"} @@ -289,6 +300,7 @@ setup: body: query: 'from test | stats med=median(count)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} @@ -303,6 +315,7 @@ setup: body: query: 'from test | stats med=median(count_d)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} @@ -317,6 +330,7 @@ setup: body: query: 'from test | stats med=median(count) by color | sort med' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} @@ -334,6 +348,7 @@ setup: body: query: 'from test | stats med=median(count_d) by color | sort med' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} @@ -351,6 +366,7 @@ setup: body: query: 'from test | stats med=median_absolute_deviation(count)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} @@ -365,6 +381,7 @@ setup: body: query: 'from test | stats med=median_absolute_deviation(count_d)' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} @@ -379,6 +396,7 @@ setup: body: query: 'from test | stats med=median_absolute_deviation(count) by color | sort color' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} @@ -396,6 +414,7 @@ setup: body: query: 'from test | stats med=median_absolute_deviation(count_d) by color | sort color' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} @@ -412,6 +431,7 @@ setup: esql.query: body: query: 'from test | stats avg_count = avg(count) | eval x = avg_count + 7' + version: 2024.04.01 - length: {values: 1} - length: {values.0: 2} @@ -425,6 +445,7 @@ setup: esql.query: body: query: 'from test | stats x = avg(count) | where x > 100' + version: 2024.04.01 - length: {values: 0} @@ -434,6 +455,7 @@ setup: esql.query: body: query: 'from test | eval nullsum = count_d + null | sort nullsum | limit 1' + version: 2024.04.01 - length: {columns: 8} - length: {values: 1} @@ -449,6 +471,7 @@ setup: esql.query: body: query: 'row a = 1, b = 2, c = null | eval z = c + b + a' + version: 2024.04.01 - length: {columns: 4} - length: {values: 1} @@ -474,6 +497,7 @@ setup: esql.query: body: query: 'from test | eval nullsum = count_d + null | stats count(nullsum)' + version: 2024.04.01 - length: {columns: 1} - length: {values: 1} @@ -490,6 +514,7 @@ setup: 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)' + version: 2024.04.01 - length: {columns: 4} - length: {values: 1} @@ -516,6 +541,7 @@ grouping on text: body: query: 'FROM test | STATS med=median(count) BY text | SORT med' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/25_aggs_on_null.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/25_aggs_on_null.yml index 0684939932774..1980ed8bb040c 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/25_aggs_on_null.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/25_aggs_on_null.yml @@ -39,6 +39,7 @@ group on null: body: query: 'FROM test | STATS med=median(never_null) BY always_null | LIMIT 1' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} - match: {columns.1.name: "always_null"} @@ -54,6 +55,7 @@ group on null, long: body: query: 'FROM test | STATS med=median(sometimes_null) BY always_null, never_null | SORT always_null, never_null | LIMIT 10' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} - match: {columns.1.name: "always_null"} @@ -72,6 +74,7 @@ agg on null: body: query: 'FROM test | STATS med=median(always_null) | LIMIT 1' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} - length: {values: 1} @@ -85,6 +88,7 @@ agg on missing: body: query: 'FROM test | STATS med=median(missing) | LIMIT 1' columnar: true + version: 2024.04.01 --- group on missing: @@ -94,6 +98,7 @@ group on missing: body: query: 'FROM test | STATS med=median(never_null) BY missing | LIMIT 1' columnar: true + version: 2024.04.01 --- agg on half missing: @@ -119,6 +124,7 @@ agg on half missing: body: query: 'FROM test* | STATS med=median(missing) | LIMIT 1' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} - length: {values: 1} @@ -148,6 +154,7 @@ group on half missing: body: query: 'FROM test,test2 | STATS med=median(never_null) BY missing | LIMIT 1' columnar: true + version: 2024.04.01 - match: {columns.0.name: "med"} - match: {columns.0.type: "double"} - match: {columns.1.name: "missing"} diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/30_types.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/30_types.yml index 9dded5d0855c6..bbf8b33445fa3 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/30_types.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/30_types.yml @@ -35,6 +35,7 @@ constant_keyword: esql.query: body: query: 'from test' + version: 2024.04.01 - match: { columns.0.name: color } - match: { columns.0.type: keyword } - match: { columns.1.name: kind } @@ -49,7 +50,7 @@ constant_keyword: esql.query: body: query: 'from test | eval l=length(kind) | keep l' - + version: 2024.04.01 - match: {columns.0.name: l} - match: {columns.0.type: integer} - length: {values: 1} @@ -80,6 +81,7 @@ constant_keyword with null value: esql.query: body: query: 'from test | limit 1' + version: 2024.04.01 - match: { columns.0.name: color } - match: { columns.0.type: keyword } - match: { columns.1.name: kind } @@ -113,6 +115,7 @@ multivalued keyword: esql.query: body: query: 'from test' + version: 2024.04.01 - match: {columns.0.name: card} - match: {columns.0.type: keyword} - length: {values: 1} @@ -144,6 +147,7 @@ keyword no doc_values: esql.query: body: query: 'from test' + version: 2024.04.01 - match: {columns.0.name: card} - match: {columns.0.type: keyword} - length: {values: 1} @@ -174,6 +178,7 @@ wildcard: esql.query: body: query: 'from test' + version: 2024.04.01 - match: {columns.0.name: card} - match: {columns.0.type: keyword} - length: {values: 1} @@ -185,6 +190,7 @@ wildcard: esql.query: body: query: 'from test | eval l=length(card) | keep l' + version: 2024.04.01 - match: {columns.0.name: l} - match: {columns.0.type: integer} - length: {values: 1} @@ -225,6 +231,7 @@ numbers: esql.query: body: query: 'from test' + version: 2024.04.01 - match: {columns.0.name: d} - match: {columns.0.type: double} - match: {columns.1.name: i} @@ -276,6 +283,7 @@ small_numbers: esql.query: body: query: 'from test' + version: 2024.04.01 - match: {columns.0.name: b} - match: {columns.0.type: integer} - match: {columns.1.name: f} @@ -296,6 +304,7 @@ small_numbers: esql.query: body: query: 'from test | eval sum_d = b + f + hf + s, sum_i = b + s | keep sum_d, sum_i' + version: 2024.04.01 - match: {columns.0.name: sum_d} - match: {columns.0.type: double} - match: {columns.1.name: sum_i} @@ -310,6 +319,7 @@ small_numbers: esql.query: body: query: 'from test | eval r_f = round(f), r_hf = round(hf) | keep r_f, r_hf' + version: 2024.04.01 - match: {columns.0.name: r_f} - match: {columns.0.type: double} - match: {columns.1.name: r_hf} @@ -346,6 +356,7 @@ scaled_float: esql.query: body: query: 'from test' + version: 2024.04.01 - match: {columns.0.name: d} - match: {columns.0.type: double} - match: {columns.1.name: f} @@ -360,6 +371,7 @@ scaled_float: esql.query: body: query: 'from test | eval sum = d + f | keep sum' + version: 2024.04.01 - match: {columns.0.name: sum} - match: {columns.0.type: double} - length: {values: 1} @@ -390,6 +402,7 @@ multivalued boolean: esql.query: body: query: 'from test' + version: 2024.04.01 - match: { columns.0.name: booleans } - match: { columns.0.type: boolean } - length: { values: 1 } @@ -422,6 +435,7 @@ ip: esql.query: body: query: 'from test' + version: 2024.04.01 - match: { columns.0.name: ip } - match: { columns.0.type: ip } - match: { columns.1.name: keyword } @@ -436,7 +450,7 @@ ip: esql.query: body: query: 'from test | where keyword == "127.0.0.2" | rename ip as IP | drop keyword' - + version: 2024.04.01 - match: {columns.0.name: IP } - match: {columns.0.type: ip } - length: {values: 1 } @@ -492,6 +506,7 @@ alias: esql.query: body: query: 'from test | keep foo, bar, level1.level2, level2_alias, some_long, some_long_alias, some_long_alias2, some_date, some_date_alias | sort level2_alias' + version: 2024.04.01 - match: { columns.0.name: foo } - match: { columns.0.type: keyword } - match: { columns.1.name: bar } @@ -536,6 +551,7 @@ alias: esql.query: body: query: 'from test | where bar == "abc" | keep foo, bar, level1.level2, level2_alias' + version: 2024.04.01 - match: { columns.0.name: foo } - match: { columns.0.type: keyword } - match: { columns.1.name: bar } @@ -556,6 +572,7 @@ alias: esql.query: body: query: 'from test | where level2_alias == 10 | keep foo, bar, level1.level2, level2_alias' + version: 2024.04.01 - match: { columns.0.name: foo } - match: { columns.0.type: keyword } - match: { columns.1.name: bar } @@ -576,6 +593,7 @@ alias: esql.query: body: query: 'from test | where level2_alias == 20' + version: 2024.04.01 - length: { values: 0 } - do: @@ -584,6 +602,7 @@ alias: esql.query: body: query: 'from test | stats x = max(level2_alias)' + version: 2024.04.01 - match: { columns.0.name: x } - match: { columns.0.type: long } - length: { values: 1 } @@ -614,6 +633,7 @@ version: esql.query: body: query: 'from test' + version: 2024.04.01 - match: { columns.0.name: version } - match: { columns.0.type: version } - length: { values: 1 } @@ -647,6 +667,7 @@ id: esql.query: body: query: 'from test metadata _id | keep _id, kw' + version: 2024.04.01 - match: { columns.0.name: _id } - match: { columns.0.type: keyword } - length: { values: 1 } @@ -678,6 +699,7 @@ unsigned_long: esql.query: body: query: 'from test' + version: 2024.04.01 - match: { columns.0.name: number } - match: { columns.0.type: unsigned_long } - length: { values: 1 } @@ -701,6 +723,7 @@ _source: esql.query: body: query: 'FROM test METADATA _source | KEEP _source | LIMIT 1' + version: 2024.04.01 - match: { columns.0.name: _source } - match: { columns.0.type: _source } - length: { values: 1 } @@ -736,6 +759,7 @@ _source keep all: esql.query: body: query: 'FROM test METADATA _source | LIMIT 1' + version: 2024.04.01 - match: { columns.0.name: _source } - match: { columns.0.type: _source } - length: { values: 1 } @@ -772,6 +796,7 @@ _source disabled: esql.query: body: query: 'FROM test METADATA _source | KEEP _source | LIMIT 1' + version: 2024.04.01 - match: { columns.0.name: _source } - match: { columns.0.type: _source } - length: { values: 1 } @@ -800,6 +825,7 @@ text: esql.query: body: query: 'FROM test | LIMIT 1' + version: 2024.04.01 - match: {columns.0.name: card} - match: {columns.0.type: text} - length: {values: 1} @@ -831,6 +857,7 @@ synthetic _source text stored: esql.query: body: query: 'FROM test | LIMIT 1' + version: 2024.04.01 - match: {columns.0.name: card} - match: {columns.0.type: text} - length: {values: 1} @@ -864,6 +891,7 @@ synthetic _source text with parent keyword: esql.query: body: query: 'FROM test | KEEP card.text | LIMIT 1' + version: 2024.04.01 - match: {columns.0.name: card.text} - match: {columns.0.type: text} - length: {values: 1} @@ -897,6 +925,7 @@ geo_point: esql.query: body: query: 'from test' + version: 2024.04.01 - match: { columns.0.name: location } - match: { columns.0.type: geo_point } - length: { values: 1 } @@ -930,6 +959,7 @@ cartesian_point: esql.query: body: query: 'from test' + version: 2024.04.01 - match: { columns.0.name: location } - match: { columns.0.type: cartesian_point } - length: { values: 1 } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/40_tsdb.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/40_tsdb.yml index 7549d33b4de1c..30b81860f014f 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/40_tsdb.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/40_tsdb.yml @@ -117,6 +117,7 @@ load everything: esql.query: body: query: 'from test metadata _id' + version: 2024.04.01 - match: {columns.0.name: "@timestamp"} - match: {columns.0.type: "date"} @@ -143,6 +144,7 @@ load a document: esql.query: body: query: 'from test | where @timestamp == "2021-04-28T18:50:23.142Z"' + version: 2024.04.01 - length: {values: 1} - length: {values.0: 7} @@ -161,6 +163,7 @@ filter on counter: esql.query: body: query: 'from test | where k8s.pod.network.tx == 1434577921' + version: 2024.04.01 --- from doc with aggregate_metric_double: @@ -171,6 +174,7 @@ from doc with aggregate_metric_double: esql.query: body: query: 'from test2' + version: 2024.04.01 - match: {columns.0.name: "@timestamp"} - match: {columns.0.type: "date"} @@ -191,6 +195,7 @@ stats on aggregate_metric_double: esql.query: body: query: 'FROM test2 | STATS max(agg_metric) BY dim' + version: 2024.04.01 --- from index pattern unsupported counter: @@ -201,6 +206,7 @@ from index pattern unsupported counter: esql.query: body: query: 'FROM test*' + version: 2024.04.01 - match: {columns.0.name: "@timestamp"} - match: {columns.0.type: "date"} @@ -229,6 +235,7 @@ from index pattern explicit counter use: esql.query: body: query: 'FROM test* | keep *.tx' + version: 2024.04.01 --- @@ -249,6 +256,7 @@ _source: esql.query: body: query: 'FROM test METADATA _source | WHERE @timestamp == "2021-04-28T18:50:23.142Z" | KEEP _source | LIMIT 1' + version: 2024.04.01 - match: { columns.0.name: _source } - match: { columns.0.type: _source } - length: { values: 1 } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/40_unsupported_types.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/40_unsupported_types.yml index c34666bb12b02..1ff0b8763c2eb 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/40_unsupported_types.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/40_unsupported_types.yml @@ -120,6 +120,7 @@ unsupported: esql.query: body: query: 'from test' + version: 2024.04.01 - match: { columns.0.name: aggregate_metric_double } - match: { columns.0.type: unsupported } @@ -217,6 +218,7 @@ unsupported: esql.query: body: query: 'from test | limit 0' + version: 2024.04.01 - match: { columns.0.name: aggregate_metric_double } - match: { columns.0.type: unsupported } - match: { columns.1.name: binary } @@ -283,6 +285,7 @@ unsupported: esql.query: body: query: 'from test | keep histogram | limit 0' + version: 2024.04.01 - match: { columns.0.name: histogram } - match: { columns.0.type: unsupported } - length: { values: 0 } @@ -300,6 +303,7 @@ unsupported with sort: esql.query: body: query: 'from test | sort some_doc.bar' + version: 2024.04.01 - match: { columns.0.name: aggregate_metric_double } - match: { columns.0.type: unsupported } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/45_non_tsdb_counter.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/45_non_tsdb_counter.yml index 05ba568838fe4..7f78ee1c7b099 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/45_non_tsdb_counter.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/45_non_tsdb_counter.yml @@ -66,6 +66,7 @@ load everything: esql.query: body: query: 'from test' + version: 2024.04.01 - match: {columns.0.name: "@timestamp"} - match: {columns.0.type: "date"} @@ -91,6 +92,7 @@ load a document: esql.query: body: query: 'from test | where @timestamp == "2021-04-28T18:50:23.142Z"' + version: 2024.04.01 - length: {values: 1} - length: {values.0: 7} @@ -110,6 +112,7 @@ filter on counter: esql.query: body: query: 'from test | where k8s.pod.network.tx == 1434577921' + version: 2024.04.01 - length: {values: 1} - length: {values.0: 7} diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/50_index_patterns.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/50_index_patterns.yml index d8aad27534433..ff04eec1d1737 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/50_index_patterns.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/50_index_patterns.yml @@ -51,6 +51,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | keep message1, message2 | sort message1' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -67,6 +68,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | keep message1, message2 | sort message1 | limit 2' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -81,6 +83,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | keep message1, message2 | sort message1 desc nulls last | limit 1' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -95,6 +98,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | keep message1, message2 | sort message1, message2' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -113,6 +117,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | keep message1, message2 | sort message1, message2 | limit 3' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -130,6 +135,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | keep message1, message2 | sort message1 desc nulls first, message2 | limit 3' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -146,6 +152,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | keep message1, message2 | sort message1, message2 | limit 2' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -162,6 +169,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | keep message1, message2 | sort message1 nulls first, message2' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -182,6 +190,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | keep message1, message2 | sort message1 nulls first, message2 nulls first' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -202,6 +211,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | keep message1, message2 | sort message1 desc nulls first, message2 desc nulls first' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -222,6 +232,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | where message1 == "foo1" | keep message1, message2 | sort message1, message2' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -236,6 +247,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | where message1 == "foo1" or message2 == 2 | keep message1, message2 | sort message1, message2' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -252,6 +264,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | stats x = max(message2)' + version: 2024.04.01 - match: { columns.0.name: x } - match: { columns.0.type: long } - length: { values: 1 } @@ -263,6 +276,7 @@ disjoint_mappings: esql.query: body: query: 'from test1,test2 | sort message1, message2 | eval x = message1, y = message2 + 1 | keep message1, message2, x, y' + version: 2024.04.01 - match: { columns.0.name: message1 } - match: { columns.0.type: keyword } - match: { columns.1.name: message2 } @@ -338,6 +352,7 @@ same_name_different_type: esql.query: body: query: 'from test1,test2' + version: 2024.04.01 - match: { columns.0.name: message } - match: { columns.0.type: unsupported } - length: { values: 4 } @@ -389,6 +404,7 @@ same_name_different_type_same_family: esql.query: body: query: 'from test1,test2 | sort message | keep message' + version: 2024.04.01 - match: { columns.0.name: message } - match: { columns.0.type: keyword } - length: { values: 4 } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_enrich.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_enrich.yml index 8a5d3be6758e3..8fbc4be3cfb3b 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_enrich.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_enrich.yml @@ -103,6 +103,7 @@ teardown: esql.query: body: query: 'from test | enrich city_codes_policy on city_id | keep name, city, country | sort name' + version: 2024.04.01 - match: { columns.0.name: "name" } - match: { columns.0.type: "keyword" } @@ -126,6 +127,7 @@ teardown: esql.query: body: query: 'from test | keep name, city_id | enrich city_codes_policy on city_id with country | sort name' + version: 2024.04.01 - match: { columns.0.name: "name" } - match: { columns.0.type: "keyword" } @@ -149,6 +151,7 @@ teardown: esql.query: body: query: 'from test | keep name, city_id | enrich city_codes_policy on city_id with country_name = country | sort name' + version: 2024.04.01 - match: { columns.0.name: "name" } - match: { columns.0.type: "keyword" } @@ -176,6 +179,7 @@ teardown: esql.query: body: query: 'from test | keep name, city_name | enrich city_names_policy on city_name | sort name' + version: 2024.04.01 - match: { columns.0.name: "name" } - match: { columns.0.type: "keyword" } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml index 74c0e9ef1bb31..018106cf1aa11 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml @@ -52,6 +52,7 @@ setup: esql.query: body: query: 'from test | where data > 2 | sort count desc | limit 5 | stats m = max(data)' + version: 2024.04.01 - do: {xpack.usage: {}} - match: { esql.available: true } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/61_enrich_ip.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/61_enrich_ip.yml index 076bf116292d0..a9ea9c704e6e8 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/61_enrich_ip.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/61_enrich_ip.yml @@ -115,6 +115,7 @@ teardown: esql.query: body: query: 'FROM events | eval ip_str = to_string(ip) | ENRICH networks-policy ON ip_str | sort @timestamp | KEEP ip, name, department, message' + version: 2024.04.01 - match: { columns.0.name: "ip" } - match: { columns.0.type: "ip" } @@ -143,6 +144,7 @@ teardown: esql.query: body: query: 'FROM events_text | ENRICH networks-policy ON ip_text | sort @timestamp | KEEP ip_text, name, department, message' + version: 2024.04.01 - match: { columns.0.name: "ip_text" } - match: { columns.0.type: "text" } @@ -170,6 +172,7 @@ teardown: esql.query: body: query: 'FROM events | eval ip_str = concat("invalid_", to_string(ip)) | ENRICH networks-policy ON ip_str | sort @timestamp | KEEP ip, name, department, message' + version: 2024.04.01 --- "IP": @@ -183,6 +186,7 @@ teardown: esql.query: body: query: 'FROM events | ENRICH networks-policy ON ip | sort @timestamp | KEEP ip, name, department, message' + version: 2024.04.01 - match: { columns.0.name: "ip" } - match: { columns.0.type: "ip" } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/62_extra_enrich.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/62_extra_enrich.yml index 19b08007fe18a..288c17bac1d16 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/62_extra_enrich.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/62_extra_enrich.yml @@ -44,6 +44,7 @@ esql.query: body: query: 'ROW name="engineering" | ENRICH departments-policy | LIMIT 10 | KEEP name, employees' + version: 2024.04.01 - match: { columns.0.name: "name" } - match: { columns.0.type: "keyword" } @@ -58,6 +59,7 @@ esql.query: body: query: 'ROW name="sales" | ENRICH departments-policy ON name WITH department=name | WHERE name==department | KEEP name, department | LIMIT 10' + version: 2024.04.01 - match: { columns.0.name: "name" } - match: { columns.0.type: "keyword" } @@ -257,6 +259,7 @@ movies: SORT total DESC, title ASC | KEEP total, title | LIMIT 10 + version: 2024.04.01 - match: { columns.0.name: "total" } - match: { columns.0.type: "long" } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/70_locale.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/70_locale.yml index e181f77f2bcef..a0ec659b21d0e 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/70_locale.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/70_locale.yml @@ -32,6 +32,7 @@ setup: esql.query: body: query: 'FROM events | eval fixed_format = date_format("MMMM", @timestamp), variable_format = date_format(format, @timestamp) | sort @timestamp | keep @timestamp, fixed_format, variable_format' + version: 2024.04.01 - match: { columns.0.name: "@timestamp" } - match: { columns.0.type: "date" } @@ -54,6 +55,7 @@ setup: body: query: 'FROM events | eval fixed_format = date_format("MMMM", @timestamp), variable_format = date_format(format, @timestamp) | sort @timestamp | keep @timestamp, fixed_format, variable_format' locale: "it-IT" + version: 2024.04.01 - match: { columns.0.name: "@timestamp" } - match: { columns.0.type: "date" } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/80_text.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/80_text.yml index 9607b64385721..c8867b2d1bf88 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/80_text.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/80_text.yml @@ -41,6 +41,7 @@ setup: esql.query: body: query: 'from test | sort emp_no' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -66,6 +67,7 @@ setup: esql.query: body: query: 'from test | where tag == "baz" | keep emp_no, name, job, tag' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -87,6 +89,7 @@ setup: esql.query: body: query: 'from test | where tag LIKE "*az" | keep emp_no, name, job, tag' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -108,6 +111,7 @@ setup: esql.query: body: query: 'from test | where tag RLIKE ".*az" | keep emp_no, name, job, tag' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -133,6 +137,7 @@ setup: esql.query: body: query: 'from test | where tag IN ("abc", "baz") | keep emp_no, name, job, tag' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -158,6 +163,7 @@ setup: esql.query: body: query: 'from test | where tag IN ("abc", tag) | keep emp_no, name, job, tag | sort emp_no' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -184,6 +190,7 @@ setup: esql.query: body: query: 'from test | where tag NOT IN ("abc", "baz") | keep emp_no, name, job, tag' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -205,6 +212,7 @@ setup: esql.query: body: query: 'from test | eval x = tag | where x == "baz" | keep emp_no, name, job, x' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -226,6 +234,7 @@ setup: esql.query: body: query: 'from test | where job == "IT Director" | keep emp_no, name, job, tag' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -247,6 +256,7 @@ setup: esql.query: body: query: 'from test | where job LIKE "*Specialist" | keep emp_no, name, job, tag' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -268,6 +278,7 @@ setup: esql.query: body: query: 'from test | where job RLIKE ".*Specialist" | keep emp_no, name, job, tag' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -290,6 +301,7 @@ setup: esql.query: body: query: 'from test | sort tag | keep emp_no, name, job, tag' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -313,6 +325,7 @@ setup: esql.query: body: query: 'from test | sort job | keep emp_no, name, job, tag' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -335,6 +348,7 @@ setup: esql.query: body: query: 'from test | sort job desc | keep emp_no, name, job, tag' + version: 2024.04.01 - match: { columns.0.name: "emp_no" } - match: { columns.0.type: "long" } @@ -358,6 +372,7 @@ setup: esql.query: body: query: 'from test | sort name | eval description = concat(name, " - ", job) | keep description' + version: 2024.04.01 - match: { columns.0.name: "description" } - match: { columns.0.type: "keyword" } @@ -378,6 +393,7 @@ setup: esql.query: body: query: 'from test | sort emp_no | eval split = split(tag, " ") | keep split' + version: 2024.04.01 - match: { columns.0.name: "split" } - match: { columns.0.type: "keyword" } @@ -395,6 +411,7 @@ setup: esql.query: body: query: 'from test | stats jobs = count(job) | keep jobs' + version: 2024.04.01 - match: { columns.0.name: "jobs" } - match: { columns.0.type: "long" } @@ -411,6 +428,7 @@ setup: esql.query: body: query: 'from test | stats tags = count(tag) | keep tags' + version: 2024.04.01 - match: { columns.0.name: "tags" } - match: { columns.0.type: "long" } @@ -427,6 +445,7 @@ setup: esql.query: body: query: 'from test | stats names = count(name) by job | keep names' + version: 2024.04.01 - match: { columns.0.name: "names" } - match: { columns.0.type: "long" } @@ -444,6 +463,7 @@ setup: esql.query: body: query: 'from test | stats names = count(name) by tag | keep names' + version: 2024.04.01 - match: { columns.0.name: "names" } - match: { columns.0.type: "long" } @@ -488,6 +508,7 @@ setup: esql.query: body: query: 'from test2 | sort emp_no | keep job' + version: 2024.04.01 - match: { columns.0.name: "job" } - match: { columns.0.type: "text" } @@ -531,6 +552,7 @@ setup: esql.query: body: query: 'from test2 | sort emp_no | keep job' + version: 2024.04.01 - match: { columns.0.name: "job" } - match: { columns.0.type: "text" } @@ -549,6 +571,7 @@ values: esql.query: body: query: 'FROM test | STATS job = VALUES(job) | EVAL job = MV_SORT(job) | LIMIT 1' + version: 2024.04.01 - match: { columns.0.name: "job" } - match: { columns.0.type: "text" } - length: { values: 1 } @@ -566,6 +589,7 @@ values: esql.query: body: query: 'FROM test | STATS job = VALUES(job) BY tag | EVAL job = MV_SORT(job) | SORT tag | LIMIT 10' + version: 2024.04.01 - match: { columns.0.name: "tag" } - match: { columns.0.type: "text" } - match: { columns.1.name: "job" } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/81_text_exact_subfields.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/81_text_exact_subfields.yml index a3be4221712fc..20dd668e0f8c3 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/81_text_exact_subfields.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/81_text_exact_subfields.yml @@ -57,6 +57,7 @@ setup: esql.query: body: query: 'from test | sort emp_no | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -83,6 +84,7 @@ setup: esql.query: body: query: 'from test | where text_ignore_above == "this" | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -106,6 +108,7 @@ setup: esql.query: body: query: 'from test | where text_ignore_above == "this is a long text" | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -130,6 +133,7 @@ setup: esql.query: body: query: 'from test | where text_ignore_above is null | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -153,6 +157,7 @@ setup: esql.query: body: query: 'from test | where text_ignore_above is not null | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -176,6 +181,7 @@ setup: esql.query: body: query: 'from test | where text_ignore_above LIKE "*long*" | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -201,6 +207,7 @@ setup: esql.query: body: query: 'from test | where text_normalizer == "CamelCase" | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -225,6 +232,7 @@ setup: esql.query: body: query: 'from test | where text_normalizer == text_normalizer.raw | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -242,7 +250,6 @@ setup: - length: { values: 1 } - match: { values.0: [ "this", "this", "abc", "abc", "bar", "bar" ]} - --- "sort ignore above": - do: @@ -251,6 +258,7 @@ setup: esql.query: body: query: 'from test | sort text_ignore_above asc | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -275,6 +283,7 @@ setup: esql.query: body: query: 'from test | sort text_ignore_above desc | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -299,6 +308,7 @@ setup: esql.query: body: query: 'from test | sort text_ignore_above asc nulls first | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -323,6 +333,7 @@ setup: esql.query: body: query: 'from test | sort text_ignore_above asc nulls last | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -341,8 +352,6 @@ setup: - match: { values.0: [ "this", "this", "abc", "abc", "bar", "bar" ]} - match: { values.1: [ "this is a long text", null, "CamelCase", "camelcase", "foo", "foo"] } - - --- "sort normalizer": - do: @@ -351,6 +360,7 @@ setup: esql.query: body: query: 'from test | sort text_normalizer asc | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -369,13 +379,13 @@ setup: - match: { values.0: [ "this is a long text", null, "CamelCase", "camelcase", "foo", "foo"] } - match: { values.1: [ "this", "this", "abc", "abc", "bar", "bar" ]} - - do: allowed_warnings_regex: - "No limit defined, adding default limit of \\[.*\\]" esql.query: body: query: 'from test | sort text_normalizer desc | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -394,13 +404,13 @@ setup: - match: { values.0: [ "this", "this", "abc", "abc", "bar", "bar" ]} - match: { values.1: [ "this is a long text", null, "CamelCase", "camelcase", "foo", "foo"] } - - do: allowed_warnings_regex: - "No limit defined, adding default limit of \\[.*\\]" esql.query: body: query: 'from test | sort text_normalizer.raw asc | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -428,6 +438,7 @@ setup: esql.query: body: query: 'from test | sort non_indexed asc | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -452,6 +463,7 @@ setup: esql.query: body: query: 'from test | sort non_indexed desc | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } @@ -476,6 +488,7 @@ setup: esql.query: body: query: 'from test | where non_indexed == "foo" | keep text_ignore_above, text_ignore_above.raw, text_normalizer, text_normalizer.raw, non_indexed, non_indexed.raw' + version: 2024.04.01 - match: { columns.0.name: "text_ignore_above" } - match: { columns.0.type: "text" } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/90_non_indexed.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/90_non_indexed.yml index f69854388baf3..86ff9626e0077 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/90_non_indexed.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/90_non_indexed.yml @@ -102,6 +102,7 @@ fetch: esql.query: body: query: 'from test' + version: 2024.04.01 - length: { columns: 18 } - match: { columns.0.name: boolean } diff --git a/x-pack/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index d7760eb42a1db..9c9ebf24bda87 100644 --- a/x-pack/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -1041,6 +1041,7 @@ public void testDisableFieldNameField() throws IOException { Request esql = new Request("POST", "_query"); esql.setJsonEntity(""" { + "version": "2024.04.01", "query": "FROM nofnf | LIMIT 1" }"""); // {"columns":[{"name":"dv","type":"keyword"},{"name":"no_dv","type":"keyword"}],"values":[["test",null]]} diff --git a/x-pack/qa/multi-cluster-search-security/legacy-with-basic-license/src/test/resources/rest-api-spec/test/querying_cluster/80_esql.yml b/x-pack/qa/multi-cluster-search-security/legacy-with-basic-license/src/test/resources/rest-api-spec/test/querying_cluster/80_esql.yml index 4c0bbfd7ec139..e8cd1321db73b 100644 --- a/x-pack/qa/multi-cluster-search-security/legacy-with-basic-license/src/test/resources/rest-api-spec/test/querying_cluster/80_esql.yml +++ b/x-pack/qa/multi-cluster-search-security/legacy-with-basic-license/src/test/resources/rest-api-spec/test/querying_cluster/80_esql.yml @@ -97,6 +97,7 @@ teardown: esql.query: body: query: 'FROM *:esql*,esql_* | STATS total = sum(cost) by tag | SORT tag | LIMIT 10' + version: '2024.04.01' - match: {columns.0.name: "total"} - match: {columns.0.type: "long"} @@ -127,6 +128,7 @@ teardown: gte: "2023-01-02" lte: "2023-01-03" format: "yyyy-MM-dd" + version: '2024.04.01' - match: {columns.0.name: "_index"} - match: {columns.0.type: "keyword"} @@ -198,6 +200,7 @@ teardown: esql.query: body: query: 'FROM *:esql*,esql_* | STATS total = sum(cost) by tag | SORT total DESC | LIMIT 3 | ENRICH suggestions | KEEP tag, total, phrase' + version: '2024.04.01' - match: {columns.0.name: "tag"} - match: {columns.0.type: "keyword"}