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
  • Loading branch information
morrySnow authored and dataroaring committed Aug 2, 2024
1 parent d414217 commit 8809507
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 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 @@ -55,11 +55,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
2 changes: 1 addition & 1 deletion regression-test/suites/insert_p0/insert.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ suite("insert") {
partition p2 values[('50'), ('100'))
)
distributed by hash(id) buckets 100
properties('replication_num'='1')
properties('replication_num'='1');
insert into table_test_insert1 values(1), (50);
Expand Down

0 comments on commit 8809507

Please sign in to comment.