wuchong commented on a change in pull request #8738: [FLINK-12845][sql-client] 
Execute multiple statements in command line…
URL: https://github.com/apache/flink/pull/8738#discussion_r316499652
 
 

 ##########
 File path: 
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
 ##########
 @@ -624,4 +637,56 @@ private static Terminal createDefaultTerminal() {
                        throw new SqlClientException("Error opening command 
line interface.", e);
                }
        }
+
+       /**
+        * Split a SemiColon-separated String, but ignore SemiColons in quotes.
+        */
+       static List<String> splitSemiColon(String line) {
+               boolean inSingleQuotes = false;
+               boolean inDoubleQuotes = false;
+               boolean escape = false;
+
+               // normalize
+               line = line.replaceAll("--[^\r\n]*", ""); // remove single-line 
comments
+               line = line.replaceAll("/\\*[\\w\\W]*?(?=\\*/)\\*/", ""); // 
remove double-line comments
 
 Review comment:
   This is the another concern from my side. We will lose the original text and 
character positions after replacing. 
   This will make users confused if the SQL has parser error because the 
position is not correct. 
   
   Another option is support all parsers in `flink-sql-parser`. The sql parser 
supports multi statement naturally and have proper exceptions. In this way, we 
will not need this "hack" replacing. But we may need more works. 
   
   cc @danny0405 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to