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



##########
File path: 
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
##########
@@ -264,25 +270,43 @@ public boolean executeInitialization(String content) {
      * terminal.
      */
     private void executeInteractive() {
-        isRunning = true;
-        LineReader lineReader = createLineReader(terminal);
-
         // make space from previous output and test the writer
         terminal.writer().println();
         terminal.writer().flush();
 
         // print welcome
         terminal.writer().append(CliStrings.MESSAGE_WELCOME);
 
+        LineReader lineReader = createLineReader(terminal);
+        getAndExecuteStatements(lineReader, 
ExecutionMode.INTERACTIVE_EXECUTION);
+    }
+
+    private boolean getAndExecuteStatements(LineReader lineReader, 
ExecutionMode mode) {
         // begin reading loop
+        boolean exitOnFailure = 
!mode.equals(ExecutionMode.INTERACTIVE_EXECUTION);
+        isRunning = true;
         while (isRunning) {
             // make some space to previous command
             terminal.writer().append("\n");
             terminal.flush();
 
-            String line;
+            Optional<Operation> parsedOperation = Optional.empty();
             try {
-                line = lineReader.readLine(prompt, null, inputTransformer, 
null);
+                String line = lineReader.readLine(prompt, null, 
inputTransformer, null);
+                if (line.trim().isEmpty()) {
+                    continue;
+                }
+                parsedOperation = parser.getParsedOperation();

Review comment:
       I am afraid that we need it to be stateful because when there are syntax 
error, we would like to print the detail of the parse exception, but throw 
SyntaxError to LineReader so that LineReader would reset the prompt of the 
terminal, So we need to keep the exception at least. the line checking is a 
sanity check, because we are not so familiar with Jline3, such check can help 
prevent unexpected errors.




-- 
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