From c427a8ad32391398b0fabeb93b760d117fcd3101 Mon Sep 17 00:00:00 2001 From: ChrisHegarty Date: Fri, 25 Apr 2025 09:23:37 +0100 Subject: [PATCH 1/3] test: check ES|QL SAMPLE capability before running parser tests --- .../org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java | 2 ++ .../elasticsearch/xpack/esql/parser/StatementParserTests.java | 1 + 2 files changed, 3 insertions(+) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java index 5f9c14e2fda61..a5ebb4a93d011 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java @@ -3405,6 +3405,8 @@ public void testRrfError() { } public void testRandomSampleProbability() { + assumeTrue("requires SAMPLE capability", EsqlCapabilities.Cap.SAMPLE.isEnabled() ); + var e = expectThrows(VerificationException.class, () -> analyze("FROM test | SAMPLE 1.")); assertThat(e.getMessage(), containsString("RandomSampling probability must be strictly between 0.0 and 1.0, was [1.0]")); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java index bc08f14867f56..54e9e7d2b0f94 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java @@ -3486,6 +3486,7 @@ public void testInvalidCompletion() { } public void testSample() { + assumeTrue("SAMPLE requires corresponding capability", EsqlCapabilities.Cap.SAMPLE.isEnabled()); expectError("FROM test | SAMPLE .1 2 3", "line 1:25: extraneous input '3' expecting "); expectError("FROM test | SAMPLE .1 \"2\"", "line 1:23: extraneous input '\"2\"' expecting "); expectError("FROM test | SAMPLE 1", "line 1:20: mismatched input '1' expecting {DECIMAL_LITERAL, '+', '-'}"); From 989b3858960fe89de86c7fa2c154eed920fe23aa Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Fri, 25 Apr 2025 08:37:47 +0000 Subject: [PATCH 2/3] [CI] Auto commit changes from spotless --- .../org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java index a5ebb4a93d011..fb617a78776cc 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java @@ -3405,7 +3405,7 @@ public void testRrfError() { } public void testRandomSampleProbability() { - assumeTrue("requires SAMPLE capability", EsqlCapabilities.Cap.SAMPLE.isEnabled() ); + assumeTrue("requires SAMPLE capability", EsqlCapabilities.Cap.SAMPLE.isEnabled()); var e = expectThrows(VerificationException.class, () -> analyze("FROM test | SAMPLE 1.")); assertThat(e.getMessage(), containsString("RandomSampling probability must be strictly between 0.0 and 1.0, was [1.0]")); From 22a1411747567711cda9e0a900aa13e2157ecb4e Mon Sep 17 00:00:00 2001 From: ChrisHegarty Date: Fri, 25 Apr 2025 11:04:29 +0100 Subject: [PATCH 3/3] fix telemetry test --- .../resources/rest-api-spec/test/esql/60_usage.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 40c720584dbf1..f4a6f48e27ddf 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 @@ -139,7 +139,7 @@ setup: - do: {xpack.usage: {}} - match: { esql.available: true } - match: { esql.enabled: true } - - length: { esql.features: 25 } + - length: { esql.features: 26 } - set: {esql.features.dissect: dissect_counter} - set: {esql.features.drop: drop_counter} - set: {esql.features.eval: eval_counter} @@ -165,6 +165,7 @@ setup: - set: {esql.features.fork: fork_counter} - set: {esql.features.rrf: rrf_counter} - set: {esql.features.completion: completion_counter} + - set: {esql.features.sample: sample_counter} - length: { esql.queries: 3 } - set: {esql.queries.rest.total: rest_total_counter} - set: {esql.queries.rest.failed: rest_failed_counter} @@ -220,7 +221,7 @@ setup: - gt: {esql.functions.to_long: $functions_to_long} - match: {esql.functions.coalesce: $functions_coalesce} - gt: {esql.functions.categorize: $functions_categorize} - - length: {esql.functions: 131} # check the "sister" test above for a likely update to the same esql.functions length check + - length: {esql.functions: 132} # check the "sister" test above for a likely update to the same esql.functions length check --- took: