wuchong commented on a change in pull request #15213:
URL: https://github.com/apache/flink/pull/15213#discussion_r595252949
##########
File path:
flink-table/flink-table-common/src/main/java/org/apache/flink/table/utils/PrintUtils.java
##########
@@ -145,36 +145,30 @@ public static void printAsTableauForm(
it = rows.iterator();
}
- final String borderline = PrintUtils.genBorderLine(colWidths);
- // print border line
- printWriter.println(borderline);
- // print field names
- PrintUtils.printSingleRow(colWidths, columnNames, printWriter);
- // print border line
- printWriter.println(borderline);
- printWriter.flush();
-
- long numRows = 0;
- while (it.hasNext()) {
- String[] cols = rowToString(it.next(), nullColumn, printRowKind);
+ if (it.hasNext()) {
+ final String borderline = PrintUtils.genBorderLine(colWidths);
+ // print border line
+ printWriter.println(borderline);
+ // print field names
+ PrintUtils.printSingleRow(colWidths, columnNames, printWriter);
+ // print border line
+ printWriter.println(borderline);
- // print content
- printSingleRow(colWidths, cols, printWriter);
- numRows++;
- }
+ long numRows = 0;
+ while (it.hasNext()) {
+ String[] cols = rowToString(it.next(), nullColumn,
printRowKind);
+ // print content
+ printSingleRow(colWidths, cols, printWriter);
+ numRows++;
+ }
- if (numRows > 0) {
// print border line
printWriter.println(borderline);
- }
-
- final String rowTerm;
- if (numRows > 1) {
- rowTerm = "rows";
+ final String rowTerm = numRows > 1 ? "rows" : "row";
+ printWriter.println(numRows + " " + rowTerm + " in set");
} else {
- rowTerm = "row";
+ printWriter.println("Empty set");
Review comment:
nit: we can check empty set the beginning of this method and return.
----------------------------------------------------------------
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]