Skip to content

Commit

Permalink
[fix](syntax) multi statements must delim with semicolon (#38670)
Browse files Browse the repository at this point in the history
pick from master #38670
  • Loading branch information
morrySnow committed Aug 2, 2024
1 parent d492056 commit c714d38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ options { tokenVocab = DorisLexer; }
}

multiStatements
: (statement SEMICOLON*)+ EOF
: statement (SEMICOLON+ statement)* SEMICOLON* EOF
;

singleStatement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pair<LogicalPlan, StatementContext>> 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();
Expand Down

0 comments on commit c714d38

Please sign in to comment.