use of org.apache.flink.table.utils.print.TableauStyle in project flink by apache.
the class CliTableauResultView method printStreamingResults.
private void printStreamingResults(AtomicInteger receivedRowCount) {
TableauStyle style = PrintStyle.tableauWithTypeInferredColumnWidths(resultDescriptor.getResultSchema(), resultDescriptor.getRowDataStringConverter(), resultDescriptor.maxColumnWidth(), false, true);
// print filed names
style.printBorderLine(terminal.writer());
style.printColumnNamesTableauRow(terminal.writer());
style.printBorderLine(terminal.writer());
terminal.flush();
while (true) {
final TypedResult<List<RowData>> result = sqlExecutor.retrieveResultChanges(sessionId, resultDescriptor.getResultId());
switch(result.getType()) {
case EMPTY:
try {
// prevent busy loop
Thread.sleep(1);
} catch (InterruptedException e) {
// get ctrl+c from terminal and fallback
return;
}
break;
case EOS:
if (receivedRowCount.get() > 0) {
style.printBorderLine(terminal.writer());
}
String rowTerm = getRowTerm(receivedRowCount);
terminal.writer().println("Received a total of " + receivedRowCount.get() + " " + rowTerm);
terminal.flush();
return;
case PAYLOAD:
List<RowData> changes = result.getPayload();
for (RowData change : changes) {
style.printTableauRow(style.rowFieldsToString(change), terminal.writer());
receivedRowCount.incrementAndGet();
}
break;
default:
throw new SqlExecutionException("Unknown result type: " + result.getType());
}
}
}
use of org.apache.flink.table.utils.print.TableauStyle in project flink by apache.
the class CliTableauResultView method printBatchResults.
private void printBatchResults(AtomicInteger receivedRowCount) {
final List<RowData> resultRows = waitBatchResults();
receivedRowCount.addAndGet(resultRows.size());
TableauStyle style = PrintStyle.tableauWithDataInferredColumnWidths(resultDescriptor.getResultSchema(), resultDescriptor.getRowDataStringConverter(), PrintStyle.DEFAULT_MAX_COLUMN_WIDTH, false, false);
style.print(resultRows.iterator(), terminal.writer());
}
Aggregations