From b65d5d18f06aae0d99433b97a4ca419ffdf6b541 Mon Sep 17 00:00:00 2001 From: Tommaso Teofili Date: Wed, 16 Jul 2025 10:51:20 +0200 Subject: [PATCH 1/3] Check SCORE_FUNCTION capability in VerifierTests --- muted-tests.yml | 3 -- .../xpack/esql/analysis/VerifierTests.java | 34 ++++++++++++++++--- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 7d23f9da16ec1..37fe718875ac6 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -427,9 +427,6 @@ tests: - class: org.elasticsearch.xpack.esql.expression.function.fulltext.ScoreTests method: testSerializationOfSimple {TestCase=} issue: https://github.com/elastic/elasticsearch/issues/131334 -- class: org.elasticsearch.xpack.esql.analysis.VerifierTests - method: testFullTextFunctionsOnlyAllowedInWhere - issue: https://github.com/elastic/elasticsearch/issues/131335 - class: org.elasticsearch.xpack.esql.analysis.VerifierTests method: testMatchInsideEval issue: https://github.com/elastic/elasticsearch/issues/131336 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 b44e7e8c990d0..9d072408bb44a 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 @@ -1213,7 +1213,9 @@ public void testWeightedAvg() { public void testMatchInsideEval() throws Exception { assertEquals( - "1:36: [:] operator is only supported in WHERE and STATS commands, or in EVAL within score(.) function\n" + "1:36: [:] operator is only supported in WHERE and STATS commands" + + (EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled() ? ", or in EVAL within score(.) function" : "") + + "\n" + "line 1:36: [:] operator cannot operate on [title], which is not a field from an index mapping", error("row title = \"brown fox\" | eval x = title:\"fox\" ") ); @@ -1385,22 +1387,44 @@ private void checkFullTextFunctionsOnlyAllowedInWhere(String functionName, Strin + functionName + "] " + functionType - + " is only supported in WHERE and STATS commands, or in EVAL within score(.) function" + + " is only supported in WHERE and STATS commands" + + (EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled() ? ", or in EVAL within score(.) function" : "") ) ); assertThat( error("from test | sort " + functionInvocation + " asc", fullTextAnalyzer), - containsString("[" + functionName + "] " + functionType + " is only supported in WHERE and STATS commands") + containsString( + "[" + + functionName + + "] " + + functionType + + " is only supported in WHERE and STATS commands" + + (EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled() ? ", or in EVAL within score(.) function" : "") + ) ); assertThat( error("from test | stats max_id = max(id) by " + functionInvocation, fullTextAnalyzer), - containsString("[" + functionName + "] " + functionType + " is only supported in WHERE and STATS commands") + containsString( + "[" + + functionName + + "] " + + functionType + + " is only supported in WHERE and STATS commands" + + (EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled() ? ", or in EVAL within score(.) function" : "") + ) ); if ("KQL".equals(functionName) || "QSTR".equals(functionName)) { assertThat( error("row a = " + functionInvocation, fullTextAnalyzer), - containsString("[" + functionName + "] " + functionType + " is only supported in WHERE and STATS commands") + containsString( + "[" + + functionName + + "] " + + functionType + + " is only supported in WHERE and STATS commands" + + (EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled() ? ", or in EVAL within score(.) function" : "") + ) ); } } From 2c869f59458d3b1486790e5a495abfd56718f04b Mon Sep 17 00:00:00 2001 From: Tommaso Teofili Date: Wed, 16 Jul 2025 12:04:24 +0200 Subject: [PATCH 2/3] test fix --- .../org/elasticsearch/xpack/esql/analysis/VerifierTests.java | 2 -- 1 file changed, 2 deletions(-) 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 9d072408bb44a..04e0908e72896 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 @@ -1399,7 +1399,6 @@ private void checkFullTextFunctionsOnlyAllowedInWhere(String functionName, Strin + "] " + functionType + " is only supported in WHERE and STATS commands" - + (EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled() ? ", or in EVAL within score(.) function" : "") ) ); @@ -1411,7 +1410,6 @@ private void checkFullTextFunctionsOnlyAllowedInWhere(String functionName, Strin + "] " + functionType + " is only supported in WHERE and STATS commands" - + (EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled() ? ", or in EVAL within score(.) function" : "") ) ); if ("KQL".equals(functionName) || "QSTR".equals(functionName)) { From 41ee99d7f157136aa4ab5176cde5dcb8ccbd8b14 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Wed, 16 Jul 2025 10:12:20 +0000 Subject: [PATCH 3/3] [CI] Auto commit changes from spotless --- .../xpack/esql/analysis/VerifierTests.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) 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 04e0908e72896..4951479514b72 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 @@ -1393,24 +1393,12 @@ private void checkFullTextFunctionsOnlyAllowedInWhere(String functionName, Strin ); assertThat( error("from test | sort " + functionInvocation + " asc", fullTextAnalyzer), - containsString( - "[" - + functionName - + "] " - + functionType - + " is only supported in WHERE and STATS commands" - ) + containsString("[" + functionName + "] " + functionType + " is only supported in WHERE and STATS commands") ); assertThat( error("from test | stats max_id = max(id) by " + functionInvocation, fullTextAnalyzer), - containsString( - "[" - + functionName - + "] " - + functionType - + " is only supported in WHERE and STATS commands" - ) + containsString("[" + functionName + "] " + functionType + " is only supported in WHERE and STATS commands") ); if ("KQL".equals(functionName) || "QSTR".equals(functionName)) { assertThat(