From b23c4a5096cd7aa9c0c2f748677d303da9c5caae Mon Sep 17 00:00:00 2001 From: Chen Dai Date: Wed, 30 Jun 2021 16:25:19 -0700 Subject: [PATCH] Change grammar and add UT Signed-off-by: Chen Dai --- sql/src/main/antlr/OpenSearchSQLParser.g4 | 2 +- .../org/opensearch/sql/sql/antlr/SQLSyntaxParserTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/src/main/antlr/OpenSearchSQLParser.g4 b/sql/src/main/antlr/OpenSearchSQLParser.g4 index 18c75b94ff..fe5526621f 100644 --- a/sql/src/main/antlr/OpenSearchSQLParser.g4 +++ b/sql/src/main/antlr/OpenSearchSQLParser.g4 @@ -72,7 +72,7 @@ adminStatement ; showStatement - : SHOW TABLES tableFilter? + : SHOW TABLES tableFilter ; describeStatement diff --git a/sql/src/test/java/org/opensearch/sql/sql/antlr/SQLSyntaxParserTest.java b/sql/src/test/java/org/opensearch/sql/sql/antlr/SQLSyntaxParserTest.java index 53de19a0fd..cf1ca36f02 100644 --- a/sql/src/test/java/org/opensearch/sql/sql/antlr/SQLSyntaxParserTest.java +++ b/sql/src/test/java/org/opensearch/sql/sql/antlr/SQLSyntaxParserTest.java @@ -160,4 +160,9 @@ public void canParseOrderByClause() { "SELECT name, age FROM test ORDER BY name ASC NULLS FIRST, age DESC NULLS LAST")); } + @Test + public void canNotParseShowStatementWithoutFilterClause() { + assertThrows(SyntaxCheckException.class, () -> parser.parse("SHOW TABLES")); + } + }