From 42751b76e160a7ab586079679609eab60338cc60 Mon Sep 17 00:00:00 2001 From: carlosdelest Date: Tue, 30 Jul 2024 13:24:43 +0200 Subject: [PATCH] Of course, we need to allow FROM :facepalm: --- .../org/elasticsearch/xpack/esql/analysis/Verifier.java | 3 ++- .../elasticsearch/xpack/esql/analysis/VerifierTests.java | 8 +------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java index f4beb9fe70570..bbfff5acd92b8 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java @@ -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; @@ -637,7 +638,7 @@ private static void checkMatchCommand(LogicalPlan plan, Set 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))); } }); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java index 5d0ecb17a581e..da87b9ff16c37 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java @@ -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 }