From 78560907e1e91c13331fb2acb4b2a2b5ee4e6940 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Fri, 2 Jul 2021 04:00:15 -0400 Subject: [PATCH] EQL: Remove "yet" from unsupported pipe error message (#74850) (#74875) Co-authored-by: Andrei Stefan --- .../xpack/eql/parser/LogicalPlanBuilder.java | 6 +++--- .../xpack/eql/parser/ExpressionTests.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/LogicalPlanBuilder.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/LogicalPlanBuilder.java index d17204ef5cf38..d09798300808f 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/LogicalPlanBuilder.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/LogicalPlanBuilder.java @@ -60,9 +60,9 @@ public abstract class LogicalPlanBuilder extends ExpressionBuilder { - private static final String FILTER_PIPE = "filter", HEAD_PIPE = "head", TAIL_PIPE = "tail"; + static final String FILTER_PIPE = "filter", HEAD_PIPE = "head", TAIL_PIPE = "tail"; - private static final Set SUPPORTED_PIPES = Sets.newHashSet("count", FILTER_PIPE, HEAD_PIPE, "sort", TAIL_PIPE, "unique", + static final Set SUPPORTED_PIPES = Sets.newHashSet("count", FILTER_PIPE, HEAD_PIPE, "sort", TAIL_PIPE, "unique", "unique_count"); private final UnresolvedRelation RELATION = new UnresolvedRelation(synthetic(""), null, "", false, ""); @@ -348,7 +348,7 @@ private LogicalPlan pipe(PipeContext ctx, LogicalPlan plan) { return new Tail(source(ctx), tailLimit, plan); default: - throw new ParsingException(source(ctx), "Pipe [{}] is not supported yet", name); + throw new ParsingException(source(ctx), "Pipe [{}] is not supported", name); } } diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java index d27f667e703a7..842bba1d729a0 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java @@ -34,7 +34,11 @@ import java.util.List; import static org.elasticsearch.xpack.eql.parser.AbstractBuilder.unquoteString; +import static org.elasticsearch.xpack.eql.parser.LogicalPlanBuilder.HEAD_PIPE; +import static org.elasticsearch.xpack.eql.parser.LogicalPlanBuilder.SUPPORTED_PIPES; +import static org.elasticsearch.xpack.eql.parser.LogicalPlanBuilder.TAIL_PIPE; import static org.elasticsearch.xpack.ql.TestUtils.UTC; +import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; @@ -509,4 +513,11 @@ public void testChainedComparisonsDisallowed() { + "'regex', 'regex~', ':', '+', '-', '*', '/', '%', '.', '['}", e.getMessage()); } + + public void testUnsupportedPipes() { + String pipe = randomValueOtherThanMany(Arrays.asList(HEAD_PIPE, TAIL_PIPE)::contains, () -> randomFrom(SUPPORTED_PIPES)); + ParsingException pe = expectThrows(ParsingException.class, "Expected parsing exception", + () -> parser.createStatement("process where foo == true | " + pipe)); + assertThat(pe.getMessage(), endsWith("Pipe [" + pipe + "] is not supported")); + } }