Skip to content

Commit 01c61fc

Browse files
committed
Match can't be used after STATS .. BY until filters can be pushed down below STATS (elastic#116642)
(cherry picked from commit e2e8a46)
1 parent e51dc09 commit 01c61fc

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ private static void checkFullTextQueryFunctions(LogicalPlan plan, Set<Failure> f
688688
plan,
689689
condition,
690690
Match.class,
691-
lp -> (lp instanceof Limit == false),
691+
lp -> (lp instanceof Limit == false) && (lp instanceof Aggregate == false),
692692
m -> "[" + m.functionName() + "] " + m.functionType(),
693693
failures
694694
);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,10 @@ public void testMatchFunctionNotAllowedAfterCommands() throws Exception {
11831183
"1:24: [MATCH] function cannot be used after LIMIT",
11841184
error("from test | limit 10 | where match(first_name, \"Anna\")")
11851185
);
1186+
assertEquals(
1187+
"1:47: [MATCH] function cannot be used after STATS",
1188+
error("from test | STATS c = AVG(salary) BY gender | where match(gender, \"F\")")
1189+
);
11861190
}
11871191

11881192
public void testMatchFunctionAndOperatorHaveCorrectErrorMessages() throws Exception {

0 commit comments

Comments
 (0)