JingGe commented on code in PR #23809:
URL: https://github.com/apache/flink/pull/23809#discussion_r1410463737


##########
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliTableauResultView.java:
##########
@@ -122,14 +137,83 @@ private void checkAndCleanUpQuery(boolean cleanUpQuery) {
     private void printBatchResults(AtomicInteger receivedRowCount) {
         final List<RowData> resultRows = waitBatchResults();
         receivedRowCount.addAndGet(resultRows.size());
+
+        if (printBatchEmptySet(resultRows)) return;
+        printBatchTable(resultRows);
+        printBatchFooter(resultRows.size());
+    }
+
+    /**
+     * Print "Empty set" if the given <code>resultRows</code> is empty, 
otherwise will do nothing.
+     *
+     * @return false if <code>resultRows</code> is not empty
+     */
+    public boolean printBatchEmptySet(List<RowData> resultRows) {
+
+        if (!resultRows.isEmpty()) {
+            return false;
+        }
+
+        if (!resultDescriptor.isPrintQueryTimeCost()
+                || DEFAULT_QUERY_BEGIN_TIME == queryBeginTime) {
+            terminal.writer().println("Empty set");
+        } else {
+            String timeCost =
+                    calculateTimeCostInPrintFormat(queryBeginTime, 
System.currentTimeMillis());
+            terminal.writer().println("Empty set" + timeCost);
+        }
+        terminal.writer().flush();
+        return true;
+    }
+
+    /**
+     * Print table with column names and borders
+     *
+     * @return the row number printed in the table
+     */
+    public void printBatchTable(List<RowData> resultRows) {

Review Comment:
   using two methods is more about code readability. Table and footer are two 
different concepts in this case. I would suggest keep them isolated and also 
for better maintainability, e.g. footer might be changed without need to know 
anything about the table. WDYT? 



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