Skip to content

Commit f70f64e

Browse files
committed
Match expressions use constants as query string, to match the function parameters checks
1 parent 598d5bc commit f70f64e

File tree

4 files changed

+65
-43
lines changed

4 files changed

+65
-43
lines changed

x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ regexBooleanExpression
7777
;
7878

7979
matchBooleanExpression
80-
: fieldExp=qualifiedName COLON queryString=primaryExpression
80+
: fieldExp=qualifiedName COLON queryString=constant
8181
;
8282

8383
valueExpression

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.java

Lines changed: 40 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,7 @@ public void testMetricWithGroupKeyAsAgg() {
22902290
}
22912291
}
22922292

2293-
public void testMatchOperator() {
2293+
public void testMatchOperatorConstantQueryString() {
22942294
var plan = statement("FROM test | WHERE field:\"value\"");
22952295
var filter = as(plan, Filter.class);
22962296
var match = (Match) filter.condition();
@@ -2301,5 +2301,27 @@ public void testMatchOperator() {
23012301

23022302
public void testInvalidMatchOperator() {
23032303
expectError("from test | WHERE field:", "line 1:25: mismatched input '<EOF>' expecting {QUOTED_STRING, ");
2304+
expectError(
2305+
"from test | WHERE field:CONCAT(\"hello\", \"world\")",
2306+
"line 1:25: mismatched input 'CONCAT' expecting {QUOTED_STRING, INTEGER_LITERAL, DECIMAL_LITERAL, "
2307+
);
2308+
expectError("from test | WHERE field:123::STRING", "line 1:28: mismatched input '::' expecting {<EOF>, '|', 'and', 'or'}");
2309+
expectError(
2310+
"from test | WHERE field:(true OR false)",
2311+
"line 1:25: extraneous input '(' expecting {QUOTED_STRING, INTEGER_LITERAL, DECIMAL_LITERAL, "
2312+
);
2313+
expectError(
2314+
"from test | WHERE field:another_field_or_value",
2315+
"line 1:25: mismatched input 'another_field_or_value' expecting {QUOTED_STRING, INTEGER_LITERAL, DECIMAL_LITERAL, "
2316+
);
2317+
expectError("from test | WHERE field:2+3", "line 1:26: mismatched input '+' expecting {<EOF>, '|', 'and', 'or'}");
2318+
expectError(
2319+
"from test | WHERE \"field\":\"value\"",
2320+
"line 1:26: mismatched input ':' expecting {<EOF>, '|', 'and', '::', 'or', '+', '-', '*', '/', '%'}"
2321+
);
2322+
expectError(
2323+
"from test | WHERE CONCAT(\"field\", 1):\"value\"",
2324+
"line 1:37: mismatched input ':' expecting {<EOF>, '|', 'and', '::', 'or', '+', '-', '*', '/', '%'}"
2325+
);
23042326
}
23052327
}

0 commit comments

Comments
 (0)