diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/QueryStringFunctionIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/QueryStringFunctionIT.java index d9625766be0c9..5b036654e80cf 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/QueryStringFunctionIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/QueryStringFunctionIT.java @@ -81,7 +81,7 @@ public void testQueryStringWithinEval() { """; var error = expectThrows(VerificationException.class, () -> run(query)); - assertThat(error.getMessage(), containsString("QSTR function is only supported in WHERE commands")); + assertThat(error.getMessage(), containsString("[QSTR] function is only supported in WHERE commands")); } private void createAndPopulateIndex() { diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java index b83497fae31da..c466f9ebb5e53 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java @@ -672,7 +672,7 @@ private static void checkFullTextQueryFunctions(LogicalPlan plan, Set f failures.add( fail( plan, - "{} function cannot be used after {}", + "[{}] function cannot be used after {}", ftf.functionName(), lp.sourceText().split(" ")[0].toUpperCase(Locale.ROOT) ) @@ -682,7 +682,7 @@ private static void checkFullTextQueryFunctions(LogicalPlan plan, Set f } } else { plan.forEachExpression(FullTextFunction.class, ftf -> { - failures.add(fail(ftf, "{} function is only supported in WHERE commands", ftf.functionName())); + failures.add(fail(ftf, "[{}] function is only supported in WHERE commands", ftf.functionName())); }); } } 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 0d94dfec07b5e..952a5184c6c5d 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 @@ -1094,52 +1094,52 @@ public void testQueryStringFunctionsNotAllowedAfterCommands() throws Exception { assumeTrue("skipping because QSTR is not enabled", EsqlCapabilities.Cap.QSTR_FUNCTION.isEnabled()); // Source commands - assertEquals("1:13: QSTR function cannot be used after SHOW", error("show info | where qstr(\"8.16.0\")")); - assertEquals("1:17: QSTR function cannot be used after ROW", error("row a= \"Anna\" | where qstr(\"Anna\")")); + assertEquals("1:13: [QSTR] function cannot be used after SHOW", error("show info | where qstr(\"8.16.0\")")); + assertEquals("1:17: [QSTR] function cannot be used after ROW", error("row a= \"Anna\" | where qstr(\"Anna\")")); // Processing commands assertEquals( - "1:43: QSTR function cannot be used after DISSECT", + "1:43: [QSTR] function cannot be used after DISSECT", error("from test | dissect first_name \"%{foo}\" | where qstr(\"Connection\")") ); - assertEquals("1:27: QSTR function cannot be used after DROP", error("from test | drop emp_no | where qstr(\"Anna\")")); + assertEquals("1:27: [QSTR] function cannot be used after DROP", error("from test | drop emp_no | where qstr(\"Anna\")")); assertEquals( - "1:71: QSTR function cannot be used after ENRICH", + "1:71: [QSTR] function cannot be used after ENRICH", error("from test | enrich languages on languages with lang = language_name | where qstr(\"Anna\")") ); - assertEquals("1:26: QSTR function cannot be used after EVAL", error("from test | eval z = 2 | where qstr(\"Anna\")")); + assertEquals("1:26: [QSTR] function cannot be used after EVAL", error("from test | eval z = 2 | where qstr(\"Anna\")")); assertEquals( - "1:44: QSTR function cannot be used after GROK", + "1:44: [QSTR] function cannot be used after GROK", error("from test | grok last_name \"%{WORD:foo}\" | where qstr(\"Anna\")") ); - assertEquals("1:27: QSTR function cannot be used after KEEP", error("from test | keep emp_no | where qstr(\"Anna\")")); - assertEquals("1:24: QSTR function cannot be used after LIMIT", error("from test | limit 10 | where qstr(\"Anna\")")); - assertEquals("1:35: QSTR function cannot be used after MV_EXPAND", error("from test | mv_expand last_name | where qstr(\"Anna\")")); + assertEquals("1:27: [QSTR] function cannot be used after KEEP", error("from test | keep emp_no | where qstr(\"Anna\")")); + assertEquals("1:24: [QSTR] function cannot be used after LIMIT", error("from test | limit 10 | where qstr(\"Anna\")")); + assertEquals("1:35: [QSTR] function cannot be used after MV_EXPAND", error("from test | mv_expand last_name | where qstr(\"Anna\")")); assertEquals( - "1:45: QSTR function cannot be used after RENAME", + "1:45: [QSTR] function cannot be used after RENAME", error("from test | rename last_name as full_name | where qstr(\"Anna\")") ); assertEquals( - "1:52: QSTR function cannot be used after STATS", + "1:52: [QSTR] function cannot be used after STATS", error("from test | STATS c = COUNT(emp_no) BY languages | where qstr(\"Anna\")") ); // Some combination of processing commands - assertEquals("1:38: QSTR function cannot be used after LIMIT", error("from test | keep emp_no | limit 10 | where qstr(\"Anna\")")); + assertEquals("1:38: [QSTR] function cannot be used after LIMIT", error("from test | keep emp_no | limit 10 | where qstr(\"Anna\")")); assertEquals( - "1:46: QSTR function cannot be used after MV_EXPAND", + "1:46: [QSTR] function cannot be used after MV_EXPAND", error("from test | limit 10 | mv_expand last_name | where qstr(\"Anna\")") ); assertEquals( - "1:52: QSTR function cannot be used after KEEP", + "1:52: [QSTR] function cannot be used after KEEP", error("from test | mv_expand last_name | keep last_name | where qstr(\"Anna\")") ); assertEquals( - "1:77: QSTR function cannot be used after RENAME", + "1:77: [QSTR] function cannot be used after RENAME", error("from test | STATS c = COUNT(emp_no) BY languages | rename c as total_emps | where qstr(\"Anna\")") ); assertEquals( - "1:54: QSTR function cannot be used after KEEP", + "1:54: [QSTR] function cannot be used after KEEP", error("from test | rename last_name as name | keep emp_no | where qstr(\"Anna\")") ); } @@ -1147,10 +1147,10 @@ public void testQueryStringFunctionsNotAllowedAfterCommands() throws Exception { public void testQueryStringFunctionsOnlyAllowedInWhere() throws Exception { assumeTrue("skipping because QSTR is not enabled", EsqlCapabilities.Cap.QSTR_FUNCTION.isEnabled()); - assertEquals("1:22: QSTR function is only supported in WHERE commands", error("from test | eval y = qstr(\"Anna\")")); - assertEquals("1:18: QSTR function is only supported in WHERE commands", error("from test | sort qstr(\"Connection\") asc")); - assertEquals("1:5: QSTR function is only supported in WHERE commands", error("row qstr(\"Connection\")")); - assertEquals("1:23: QSTR function is only supported in WHERE commands", error("from test | STATS c = qstr(\"foo\") BY languages")); + assertEquals("1:22: [QSTR] function is only supported in WHERE commands", error("from test | eval y = qstr(\"Anna\")")); + assertEquals("1:18: [QSTR] function is only supported in WHERE commands", error("from test | sort qstr(\"Connection\") asc")); + assertEquals("1:5: [QSTR] function is only supported in WHERE commands", error("row qstr(\"Connection\")")); + assertEquals("1:23: [QSTR] function is only supported in WHERE commands", error("from test | STATS c = qstr(\"foo\") BY languages")); } public void testQueryStringFunctionArgNotNullOrConstant() throws Exception {