Skip to content

Commit 42751b7

Browse files
committed
Of course, we need to allow FROM 🤦
1 parent ed1852e commit 42751b7

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.NotEquals;
3535
import org.elasticsearch.xpack.esql.plan.logical.Aggregate;
3636
import org.elasticsearch.xpack.esql.plan.logical.Enrich;
37+
import org.elasticsearch.xpack.esql.plan.logical.EsRelation;
3738
import org.elasticsearch.xpack.esql.plan.logical.Eval;
3839
import org.elasticsearch.xpack.esql.plan.logical.Filter;
3940
import org.elasticsearch.xpack.esql.plan.logical.Limit;
@@ -637,7 +638,7 @@ private static void checkMatchCommand(LogicalPlan plan, Set<Failure> failures) {
637638
// we can't check if it can be pushed down as we don't have yet information about the fields present in the
638639
// StringQueryPredicate
639640
plan.forEachDown(LogicalPlan.class, lp -> {
640-
if ((lp instanceof Filter || lp instanceof OrderBy) == false) {
641+
if ((lp instanceof Filter || lp instanceof OrderBy || lp instanceof EsRelation) == false) {
641642
failures.add(fail(plan, "MATCH cannot be used after {}", lp.sourceText().split(" ")[0].toUpperCase(Locale.ROOT)));
642643
}
643644
});

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,20 +660,14 @@ public void testMatchFilter() throws Exception {
660660

661661
public void testMatchCommand() throws Exception {
662662
assertEquals("1:24: MATCH cannot be used after LIMIT", error("from test | limit 10 | match \"Anna\""));
663-
664663
assertEquals("1:13: MATCH cannot be used after SHOW", error("show info | match \"8.16.0\""));
665-
666664
assertEquals("1:17: MATCH cannot be used after ROW", error("row a= \"Anna\" | match \"Anna\""));
667-
668665
assertEquals("1:26: MATCH cannot be used after EVAL", error("from test | eval z = 2 | match \"Anna\""));
669-
670666
assertEquals("1:43: MATCH cannot be used after DISSECT", error("from test | dissect first_name \"%{foo}\" | match \"Connection\""));
671-
672667
assertEquals("1:27: MATCH cannot be used after DROP", error("from test | drop emp_no | match \"Anna\""));
673-
674668
assertEquals("1:35: MATCH cannot be used after EVAL", error("from test | eval n = emp_no * 3 | match \"Anna\""));
675669
assertEquals("1:44: MATCH cannot be used after GROK", error("from test | grok last_name \"%{WORD:foo}\" | match \"Anna\""));
676-
assertEquals("1:35: MATCH cannot be used after KEEP", error("from test | eval n = emp_no * 3 | match \"Anna\""));
670+
assertEquals("1:27: MATCH cannot be used after KEEP", error("from test | keep emp_no | match \"Anna\""));
677671

678672
// TODO Keep adding tests for all unsupported commands
679673
}

0 commit comments

Comments
 (0)