Skip to content

Commit

Permalink
Of course, we need to allow FROM 🤦
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosdelest committed Jul 30, 2024
1 parent ed1852e commit 42751b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.NotEquals;
import org.elasticsearch.xpack.esql.plan.logical.Aggregate;
import org.elasticsearch.xpack.esql.plan.logical.Enrich;
import org.elasticsearch.xpack.esql.plan.logical.EsRelation;
import org.elasticsearch.xpack.esql.plan.logical.Eval;
import org.elasticsearch.xpack.esql.plan.logical.Filter;
import org.elasticsearch.xpack.esql.plan.logical.Limit;
Expand Down Expand Up @@ -637,7 +638,7 @@ private static void checkMatchCommand(LogicalPlan plan, Set<Failure> failures) {
// we can't check if it can be pushed down as we don't have yet information about the fields present in the
// StringQueryPredicate
plan.forEachDown(LogicalPlan.class, lp -> {
if ((lp instanceof Filter || lp instanceof OrderBy) == false) {
if ((lp instanceof Filter || lp instanceof OrderBy || lp instanceof EsRelation) == false) {
failures.add(fail(plan, "MATCH cannot be used after {}", lp.sourceText().split(" ")[0].toUpperCase(Locale.ROOT)));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,20 +660,14 @@ public void testMatchFilter() throws Exception {

public void testMatchCommand() throws Exception {
assertEquals("1:24: MATCH cannot be used after LIMIT", error("from test | limit 10 | match \"Anna\""));

assertEquals("1:13: MATCH cannot be used after SHOW", error("show info | match \"8.16.0\""));

assertEquals("1:17: MATCH cannot be used after ROW", error("row a= \"Anna\" | match \"Anna\""));

assertEquals("1:26: MATCH cannot be used after EVAL", error("from test | eval z = 2 | match \"Anna\""));

assertEquals("1:43: MATCH cannot be used after DISSECT", error("from test | dissect first_name \"%{foo}\" | match \"Connection\""));

assertEquals("1:27: MATCH cannot be used after DROP", error("from test | drop emp_no | match \"Anna\""));

assertEquals("1:35: MATCH cannot be used after EVAL", error("from test | eval n = emp_no * 3 | match \"Anna\""));
assertEquals("1:44: MATCH cannot be used after GROK", error("from test | grok last_name \"%{WORD:foo}\" | match \"Anna\""));
assertEquals("1:35: MATCH cannot be used after KEEP", error("from test | eval n = emp_no * 3 | match \"Anna\""));
assertEquals("1:27: MATCH cannot be used after KEEP", error("from test | keep emp_no | match \"Anna\""));

// TODO Keep adding tests for all unsupported commands
}
Expand Down

0 comments on commit 42751b7

Please sign in to comment.