wenlong88 commented on a change in pull request #18363:
URL: https://github.com/apache/flink/pull/18363#discussion_r807859596



##########
File path: 
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/parse/CalciteParser.java
##########
@@ -47,12 +49,36 @@ public CalciteParser(SqlParser.Config config) {
      * @param sql a sql string to parse
      * @return a parsed sql node
      * @throws SqlParserException if an exception is thrown when parsing the 
statement
+     * @throws SqlParserEOFException if the statement is incomplete
      */
     public SqlNode parse(String sql) {
         try {
             SqlParser parser = SqlParser.create(sql, config);
             return parser.parseStmt();
         } catch (SqlParseException e) {
+            if (e.getMessage().contains("Encountered \"<EOF>\"")) {
+                throw new SqlParserEOFException(e.getMessage(), e);
+            }
+            throw new SqlParserException("SQL parse failed. " + 
e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Parses a SQL string into a {@link SqlNodeList}. The {@link SqlNodeList} 
is not yet validated.
+     *
+     * @param sql a sql string to parse
+     * @return a parsed sql node list
+     * @throws SqlParserException if an exception is thrown when parsing the 
statement
+     * @throws SqlParserEOFException if the statement is incomplete
+     */
+    public SqlNodeList parseSqlList(String sql) {
+        try {
+            SqlParser parser = SqlParser.create(sql, config);
+            return parser.parseStmtList();
+        } catch (SqlParseException e) {
+            if (e.getMessage().contains("Encountered \"<EOF>\"")) {
+                throw new SqlParserEOFException(e.getMessage(), e);

Review comment:
       personally I like explicit subclass better, it can make code easier to 
understand.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to