From 566f8cdaeb8ba47b3b2cb28c6de0110b1b017696 Mon Sep 17 00:00:00 2001 From: James Duong Date: Thu, 7 Nov 2024 12:00:05 -0800 Subject: [PATCH] Add test for checking an invalid number of samples Signed-off-by: James Duong --- .../java/org/opensearch/sql/ppl/parser/AstBuilderTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstBuilderTest.java b/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstBuilderTest.java index 74409061fb..ad106bc03e 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstBuilderTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstBuilderTest.java @@ -7,6 +7,7 @@ import static java.util.Collections.emptyList; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.opensearch.sql.ast.dsl.AstDSL.agg; import static org.opensearch.sql.ast.dsl.AstDSL.aggregate; import static org.opensearch.sql.ast.dsl.AstDSL.alias; @@ -61,6 +62,7 @@ import org.opensearch.sql.ast.tree.Kmeans; import org.opensearch.sql.ast.tree.ML; import org.opensearch.sql.ast.tree.RareTopN.CommandType; +import org.opensearch.sql.common.antlr.SyntaxCheckException; import org.opensearch.sql.ppl.antlr.PPLSyntaxParser; public class AstBuilderTest { @@ -728,6 +730,11 @@ public void testTrendlineNoAlias() { computation(5, field("test_field"), "test_field_trendline", SMA))); } + @Test + public void testTrendlineTooFewSamples() { + assertThrows(SyntaxCheckException.class, () -> plan("source=t | trendline sma(0, test_field)")); + } + @Test public void testDescribeCommand() { assertEqual("describe t", relation(mappingTable("t")));