diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 index e9f6f094176bee..dfebbd00e74f80 100644 --- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 +++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 @@ -26,7 +26,7 @@ options { tokenVocab = DorisLexer; } } multiStatements - : (statement SEMICOLON*)+ EOF + : statement (SEMICOLON+ statement)* SEMICOLON* EOF ; singleStatement diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java index 247a24679a1e68..69ba9d85db9cd7 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java @@ -54,11 +54,18 @@ public class NereidsParserTest extends ParserTestBase { @Test public void testParseMultiple() { NereidsParser nereidsParser = new NereidsParser(); - String sql = "SELECT b FROM test;SELECT a FROM test;"; + String sql = "SELECT b FROM test;;;;SELECT a FROM test;"; List> logicalPlanList = nereidsParser.parseMultiple(sql); Assertions.assertEquals(2, logicalPlanList.size()); } + @Test + public void testParseMultipleError() { + NereidsParser nereidsParser = new NereidsParser(); + String sql = "SELECT b FROM test SELECT a FROM test;"; + Assertions.assertThrowsExactly(ParseException.class, () -> nereidsParser.parseMultiple(sql)); + } + @Test public void testSingle() { NereidsParser nereidsParser = new NereidsParser();