fsk119 commented on code in PR #25700:
URL: https://github.com/apache/flink/pull/25700#discussion_r1870570454


##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/application/Printer.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.gateway.service.application;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.gateway.api.results.ResultSet;
+import org.apache.flink.table.gateway.api.utils.SqlGatewayException;
+import org.apache.flink.table.gateway.service.result.ResultFetcher;
+import org.apache.flink.util.CloseableIterator;
+
+import javax.annotation.Nullable;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.util.Iterator;
+
+/** Printer to print the statement results in application mode. */
+public class Printer {
+
+    @VisibleForTesting public static final String STATEMENT_BEGIN = "Flink 
SQL> ";
+    @VisibleForTesting public static final String LINE_BEGIN = "> ";
+
+    @VisibleForTesting final PrintWriter writer;
+
+    public Printer() {
+        this(System.out);
+    }
+
+    public Printer(OutputStream output) {
+        this.writer = new PrintWriter(output, true);
+    }
+
+    public void print(String statement) {
+        try (BufferedReader reader = new BufferedReader(new 
StringReader(statement))) {
+            writer.print(STATEMENT_BEGIN);
+            writer.println(reader.readLine());
+            String line;
+            while ((line = reader.readLine()) != null) {
+                writer.print(LINE_BEGIN);
+                writer.println(line);

Review Comment:
   I think printer should output the content it receives. It's up to the 
ScriptExecutor whether keep the semicolon for each splitted statement. The 
`ScriptExecutor#ResultIterator` always add the current char into the buffer.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to