This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 5edcbd75571 [fix](syntax) multi statements must delim with semicolon 
(#38670) (#38752)
5edcbd75571 is described below

commit 5edcbd75571a3043196976d079a6cd360b56bcab
Author: morrySnow <[email protected]>
AuthorDate: Fri Aug 2 13:53:51 2024 +0800

    [fix](syntax) multi statements must delim with semicolon (#38670) (#38752)
    
    pick from master #38670
---
 .../src/main/antlr4/org/apache/doris/nereids/DorisParser.g4      | 2 +-
 .../java/org/apache/doris/nereids/parser/NereidsParserTest.java  | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

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 e9f6f094176..dfebbd00e74 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 247a24679a1..69ba9d85db9 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<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();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to