From 2196028c08fe113ad35afa9d731d90fa26f341d8 Mon Sep 17 00:00:00 2001 From: Andrei Stefan Date: Fri, 2 Jul 2021 10:00:51 +0300 Subject: [PATCH] EQL: Remove "yet" from unsupported pipe error message (#74850) --- .../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")); + } }