Skip to content

Commit 084b4ed

Browse files
committed
Remove snapshot from match operator capability
1 parent 78998e7 commit 084b4ed

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/MatchOperatorIT.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ public void setupIndex() {
3232
createAndPopulateIndex();
3333
}
3434

35-
@Override
36-
protected EsqlQueryResponse run(EsqlQueryRequest request) {
37-
assumeTrue("match operator capability not available", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
38-
return super.run(request);
39-
}
40-
4135
public void testSimpleWhereMatch() {
4236
var query = """
4337
FROM test

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public enum Cap {
302302
/**
303303
* Support for match operator as a colon. Previous support for match operator as MATCH has been removed
304304
*/
305-
MATCH_OPERATOR_COLON(Build.current().isSnapshot()),
305+
MATCH_OPERATOR_COLON,
306306

307307
/**
308308
* Removing support for the {@code META} keyword.

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,8 +2321,6 @@ public void testInvalidNamedParamsForIdentifierPatterns() {
23212321
}
23222322

23232323
public void testFromEnrichAndMatchColonUsage() {
2324-
assumeTrue("Match operator is available just for snapshots", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
2325-
23262324
LogicalPlan plan = analyze("""
23272325
from *:test
23282326
| EVAL x = to_string(languages)

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,8 +1159,6 @@ public void testMatchInsideEval() throws Exception {
11591159
}
11601160

11611161
public void testMatchFilter() throws Exception {
1162-
assumeTrue("Match operator is available just for snapshots", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
1163-
11641162
assertEquals(
11651163
"1:19: first argument of [salary:\"100\"] must be [string], found value [salary] type [integer]",
11661164
error("from test | where salary:\"100\"")
@@ -1190,7 +1188,6 @@ public void testMatchFunctionNotAllowedAfterCommands() throws Exception {
11901188
}
11911189

11921190
public void testMatchFunctionAndOperatorHaveCorrectErrorMessages() throws Exception {
1193-
assumeTrue("skipping because MATCH operator is not enabled", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
11941191
assertEquals(
11951192
"1:24: [MATCH] function cannot be used after LIMIT",
11961193
error("from test | limit 10 | where match(first_name, \"Anna\")")
@@ -1271,7 +1268,6 @@ public void testMatchFunctionOnlyAllowedInWhere() throws Exception {
12711268
}
12721269

12731270
public void testMatchOperatornOnlyAllowedInWhere() throws Exception {
1274-
assumeTrue("skipping because MATCH operator is not enabled", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
12751271
checkFullTextFunctionsOnlyAllowedInWhere(":", "first_name:\"Anna\"", "operator");
12761272
}
12771273

@@ -1317,8 +1313,6 @@ public void testMatchFunctionWithDisjunctions() {
13171313
}
13181314

13191315
public void testMatchOperatorWithDisjunctions() {
1320-
assumeTrue("skipping because MATCH operator is not enabled", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
1321-
13221316
checkWithDisjunctions(":", "first_name : \"Anna\"", "operator");
13231317
}
13241318

@@ -1374,7 +1368,6 @@ public void testMatchFunctionWithNonBooleanFunctions() {
13741368
}
13751369

13761370
public void testMatchOperatorWithNonBooleanFunctions() {
1377-
assumeTrue("skipping because MATCH operator is not enabled", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
13781371
checkFullTextFunctionsWithNonBooleanFunctions(":", "first_name:\"Anna\"", "operator");
13791372
}
13801373

@@ -1452,8 +1445,6 @@ public void testMatchFunctionCurrentlyUnsupportedBehaviour() throws Exception {
14521445
"1:68: Unknown column [first_name]",
14531446
error("from test | stats max_salary = max(salary) by emp_no | where match(first_name, \"Anna\")")
14541447
);
1455-
1456-
assumeTrue("skipping because MATCH operator is not enabled", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
14571448
assertEquals(
14581449
"1:62: Unknown column [first_name]",
14591450
error("from test | stats max_salary = max(salary) by emp_no | where first_name : \"Anna\"")
@@ -1473,8 +1464,6 @@ public void testMatchFunctionNullArgs() throws Exception {
14731464

14741465
public void testMatchTargetsExistingField() throws Exception {
14751466
assertEquals("1:39: Unknown column [first_name]", error("from test | keep emp_no | where match(first_name, \"Anna\")"));
1476-
1477-
assumeTrue("skipping because MATCH operator is not enabled", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
14781467
assertEquals("1:33: Unknown column [first_name]", error("from test | keep emp_no | where first_name : \"Anna\""));
14791468
}
14801469

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,10 @@ private static String buildSignatureSvg(String name) throws IOException {
816816
if (unaryOperator != null) {
817817
return RailRoadDiagram.unaryOperator(unaryOperator);
818818
}
819+
String searchOperator = searchOperator(name);
820+
if (searchOperator != null) {
821+
return RailRoadDiagram.searchOperator(searchOperator);
822+
}
819823
FunctionDefinition definition = definition(name);
820824
if (definition != null) {
821825
return RailRoadDiagram.functionSignature(definition);
@@ -1253,7 +1257,6 @@ private static String binaryOperator(String name) {
12531257
case "greater_than_or_equal" -> ">=";
12541258
case "less_than" -> "<";
12551259
case "less_than_or_equal" -> "<=";
1256-
case "match_operator" -> ":";
12571260
case "mod" -> "%";
12581261
case "mul" -> "*";
12591262
case "not_equals" -> "!=";
@@ -1262,6 +1265,16 @@ private static String binaryOperator(String name) {
12621265
};
12631266
}
12641267

1268+
/**
1269+
* If this test is a for a search operator return its symbol, otherwise return {@code null}.
1270+
*/
1271+
private static String searchOperator(String name) {
1272+
return switch (name) {
1273+
case "match_operator" -> ":";
1274+
default -> null;
1275+
};
1276+
}
1277+
12651278
/**
12661279
* If this tests is for a unary operator return its symbol, otherwise return {@code null}.
12671280
* This is functionally the reverse of {@link ExpressionBuilder#visitArithmeticUnary}.

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/RailRoadDiagram.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ static String binaryOperator(String operator) throws IOException {
8989
return toSvg(new Sequence(expressions.toArray(Expression[]::new)));
9090
}
9191

92+
/**
93+
* Generate a railroad diagram for a search operator. The output would look like
94+
* {@code field : value}.
95+
*/
96+
static String searchOperator(String operator) throws IOException {
97+
List<Expression> expressions = new ArrayList<>();
98+
expressions.add(new Literal("field"));
99+
expressions.add(new Syntax(operator));
100+
expressions.add(new Literal("value"));
101+
return toSvg(new Sequence(expressions.toArray(Expression[]::new)));
102+
}
103+
92104
/**
93105
* Generate a railroad diagram for unary operator. The output would look like
94106
* {@code -v}.

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LocalPhysicalPlanOptimizerTests.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,6 @@ public void testMissingFieldsDoNotGetExtracted() {
10921092
* estimatedRowSize[324]
10931093
*/
10941094
public void testSingleMatchFilterPushdown() {
1095-
assumeTrue("skipping because MATCH operator is not enabled", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
1096-
10971095
var plan = plannerOptimizer.plan("""
10981096
from test
10991097
| where first_name:"Anna"
@@ -1124,8 +1122,6 @@ public void testSingleMatchFilterPushdown() {
11241122
* [_doc{f}#22], limit[1000], sort[[FieldSort[field=emp_no{f}#12, direction=ASC, nulls=LAST]]] estimatedRowSize[336]
11251123
*/
11261124
public void testMultipleMatchFilterPushdown() {
1127-
assumeTrue("skipping because MATCH operator is not enabled", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
1128-
11291125
String query = """
11301126
from test
11311127
| where first_name:"Anna" and first_name:"Anneke"

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,7 +2300,6 @@ public void testMetricWithGroupKeyAsAgg() {
23002300
}
23012301

23022302
public void testMatchOperatorConstantQueryString() {
2303-
assumeTrue("skipping because MATCH operator is not enabled", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
23042303
var plan = statement("FROM test | WHERE field:\"value\"");
23052304
var filter = as(plan, Filter.class);
23062305
var match = (Match) filter.condition();
@@ -2310,7 +2309,6 @@ public void testMatchOperatorConstantQueryString() {
23102309
}
23112310

23122311
public void testInvalidMatchOperator() {
2313-
assumeTrue("skipping because MATCH operator is not enabled", EsqlCapabilities.Cap.MATCH_OPERATOR_COLON.isEnabled());
23142312
expectError("from test | WHERE field:", "line 1:25: mismatched input '<EOF>' expecting {QUOTED_STRING, ");
23152313
expectError(
23162314
"from test | WHERE field:CONCAT(\"hello\", \"world\")",

0 commit comments

Comments
 (0)