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")); + } + }