From 8b49b9451fcf91e759fbc36657073dfaa9a48856 Mon Sep 17 00:00:00 2001 From: Craig Taverner Date: Tue, 9 Sep 2025 12:11:37 +0200 Subject: [PATCH 1/5] Require capability for DECAY function --- .../esql/expression/function/scalar/score/DecayTests.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/score/DecayTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/score/DecayTests.java index fda42d74a0e30..c68896b13884d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/score/DecayTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/score/DecayTests.java @@ -13,6 +13,7 @@ import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.script.ScoreScriptUtils; +import org.elasticsearch.xpack.esql.action.EsqlCapabilities; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.expression.Literal; import org.elasticsearch.xpack.esql.core.expression.MapExpression; @@ -20,6 +21,7 @@ import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.expression.function.AbstractScalarFunctionTestCase; import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; +import org.junit.BeforeClass; import java.time.Duration; import java.time.Instant; @@ -44,6 +46,11 @@ public DecayTests(@Name("TestCase") Supplier testCase this.testCase = testCaseSupplier.get(); } + @BeforeClass + public static void checkCapability() { + assumeTrue("Decay function tests require the DECAY_FUNCTION capability", EsqlCapabilities.Cap.DECAY_FUNCTION.isEnabled()); + } + @ParametersFactory public static Iterable parameters() { List testCaseSuppliers = new ArrayList<>(); From c61b9e04a64438221ae80d1ac750b31f39636a8c Mon Sep 17 00:00:00 2001 From: Craig Taverner Date: Tue, 9 Sep 2025 15:48:29 +0200 Subject: [PATCH 2/5] Fix railroad diagrams with correct commas for optional params --- docs/reference/query-languages/esql/images/functions/decay.svg | 2 +- docs/reference/query-languages/esql/images/functions/knn.svg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/query-languages/esql/images/functions/decay.svg b/docs/reference/query-languages/esql/images/functions/decay.svg index 176ef68b5b730..03973b34d2767 100644 --- a/docs/reference/query-languages/esql/images/functions/decay.svg +++ b/docs/reference/query-languages/esql/images/functions/decay.svg @@ -1 +1 @@ -DECAY(value,origin,scale,options) \ No newline at end of file +DECAY(value,origin,scale,options) \ No newline at end of file diff --git a/docs/reference/query-languages/esql/images/functions/knn.svg b/docs/reference/query-languages/esql/images/functions/knn.svg index aefae3476031f..326dd00a40976 100644 --- a/docs/reference/query-languages/esql/images/functions/knn.svg +++ b/docs/reference/query-languages/esql/images/functions/knn.svg @@ -1 +1 @@ -KNN(field,query,options) +KNN(field,query,options) \ No newline at end of file From a9c37ee753ef4c19f1f403f856e7e7a09e28c901 Mon Sep 17 00:00:00 2001 From: Craig Taverner Date: Tue, 9 Sep 2025 15:54:21 +0200 Subject: [PATCH 3/5] Add capability to gate SET command in release tests --- .../elasticsearch/xpack/esql/action/EsqlCapabilities.java | 5 +++++ .../org/elasticsearch/xpack/esql/analysis/ParsingTests.java | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java index d9c096ab8a8c7..ffa28db2fa7af 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java @@ -1329,6 +1329,11 @@ public enum Cap { */ FIX_MV_EXPAND_INCONSISTENT_COLUMN_ORDER, + /** + * Support for the SET command. + */ + SET_COMMAND(Build.current().isSnapshot()), + /** * (Re)Added EXPLAIN command */ diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/ParsingTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/ParsingTests.java index aa9501f998d39..927872ab23cb9 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/ParsingTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/ParsingTests.java @@ -213,6 +213,7 @@ public void testInvalidSample() { } public void testSet() { + assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled()); EsqlStatement query = parse("SET foo = \"bar\"; row a = 1", new QueryParams()); assertThat(query.plan(), is(instanceOf(Row.class))); assertThat(query.settings().size(), is(1)); @@ -232,6 +233,7 @@ public void testSet() { } public void testSetWithTripleQuotes() { + assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled()); EsqlStatement query = parse("SET foo = \"\"\"bar\"baz\"\"\"; row a = 1", new QueryParams()); assertThat(query.plan(), is(instanceOf(Row.class))); assertThat(query.settings().size(), is(1)); @@ -249,6 +251,7 @@ public void testSetWithTripleQuotes() { } public void testMultipleSet() { + assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled()); EsqlStatement query = parse( "SET foo = \"bar\"; SET bar = 2; SET foo = \"baz\"; SET x = 3.5; SET y = false; SET z = null; row a = 1", new QueryParams() @@ -265,6 +268,7 @@ public void testMultipleSet() { } public void testSetArrays() { + assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled()); EsqlStatement query = parse("SET foo = [\"bar\", \"baz\"]; SET bar = [1, 2, 3]; row a = 1", new QueryParams()); assertThat(query.plan(), is(instanceOf(Row.class))); assertThat(query.settings().size(), is(2)); @@ -274,6 +278,7 @@ public void testSetArrays() { } public void testSetWithNamedParams() { + assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled()); EsqlStatement query = parse( "SET foo = \"bar\"; SET bar = ?a; SET foo = \"baz\"; SET x = ?x; row a = 1", new QueryParams( @@ -293,6 +298,7 @@ public void testSetWithNamedParams() { } public void testSetWithPositionalParams() { + assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled()); EsqlStatement query = parse( "SET foo = \"bar\"; SET bar = ?; SET foo = \"baz\"; SET x = ?; row a = ?", new QueryParams( From f6b2b74c1c6d2db98677a62c96e21461c1096fda Mon Sep 17 00:00:00 2001 From: Craig Taverner Date: Tue, 9 Sep 2025 17:01:58 +0200 Subject: [PATCH 4/5] Gate new INLINESTATS test with capability --- .../org/elasticsearch/xpack/esql/analysis/VerifierTests.java | 2 ++ .../xpack/esql/optimizer/OptimizerVerificationTests.java | 1 + 2 files changed, 3 insertions(+) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java index cbbbe7bbeceff..3b884921d05be 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java @@ -2069,6 +2069,8 @@ public void testCategorizeOptionSimilarityThreshold() { } public void testCategorizeWithInlineStats() { + assumeTrue("CATEGORIZE must be enabled", EsqlCapabilities.Cap.CATEGORIZE_V6.isEnabled()); + assumeTrue("INLINESTATS must be enabled", EsqlCapabilities.Cap.INLINESTATS_V11.isEnabled()); assertEquals( "1:37: CATEGORIZE [CATEGORIZE(last_name, { \"similarity_threshold\": 1 })] is not yet supported with " + "INLINESTATS [INLINESTATS COUNT(*) BY CATEGORIZE(last_name, { \"similarity_threshold\": 1 })]", diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/OptimizerVerificationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/OptimizerVerificationTests.java index 4e1ba54636160..df7940b0d9f8e 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/OptimizerVerificationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/OptimizerVerificationTests.java @@ -431,6 +431,7 @@ public void testRemoteEnrichAfterLookupJoinWithPipelineBreaker() { } public void testDanglingOrderByInInlineStats() { + assumeTrue("INLINESTATS must be enabled", EsqlCapabilities.Cap.INLINESTATS_V11.isEnabled()); var analyzer = AnalyzerTestUtils.analyzer(loadMapping("mapping-default.json", "test")); var err = error(""" From bdd96ec3e21b4258efd80d9cef83eaf56f6c6d42 Mon Sep 17 00:00:00 2001 From: Craig Taverner Date: Tue, 9 Sep 2025 18:34:01 +0200 Subject: [PATCH 5/5] Change function count after moving from SNAPSHOT --- .../yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5f2470675714d..670caf440f8d6 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 @@ -225,7 +225,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: 142} # check the "sister" test above for a likely update to the same esql.functions length check + - length: {esql.functions: 144} # check the "sister" test above for a likely update to the same esql.functions length check --- took: