use of io.confluent.ksql.cli.console.table.Table.Builder in project ksql by confluentinc.
the class FunctionNameListTableBuilder method buildTable.
@Override
public Table buildTable(final FunctionNameList functionNameList) {
final Builder builder = new Builder().withColumnHeaders(HEADERS);
// poor mans version check for the case we are running against an older ksqlDB server
final Iterator<SimpleFunctionInfo> funcs = functionNameList.getFunctions().iterator();
if (!funcs.hasNext() || funcs.next().getCategory().isEmpty()) {
final Stream<List<String>> rows = functionNameList.getFunctions().stream().sorted(Comparator.comparing(SimpleFunctionInfo::getName)).map(func -> ImmutableList.of(func.getName(), func.getType().name().toUpperCase()));
builder.withRows(rows);
} else {
// category info present, use new display layout
final List<SimpleFunctionInfo> sortedFunctions = functionNameList.getFunctions().stream().sorted(Comparator.comparing(SimpleFunctionInfo::getCategory).thenComparing(SimpleFunctionInfo::getName)).collect(Collectors.toList());
String prevCategory = sortedFunctions.get(0).getCategory();
for (SimpleFunctionInfo fn : sortedFunctions) {
if (!fn.getCategory().equals(prevCategory)) {
builder.withRow(EMPTY_ROW);
}
builder.withRow(fn.getName(), fn.getCategory());
prevCategory = fn.getCategory();
}
}
builder.withFooterLine("For detailed information about a function, run: DESCRIBE FUNCTION <Function Name>;");
return builder.build();
}
use of io.confluent.ksql.cli.console.table.Table.Builder in project ksql by confluentinc.
the class TopicDescriptionTableBuilder method buildTable.
@Override
public Table buildTable(final TopicDescription topicDescription) {
final String format = topicDescription.getFormat();
final boolean supportsSchema = FormatFactory.fromName(format).supportsFeature(SerdeFeature.SCHEMA_INFERENCE);
final List<String> headings = supportsSchema ? SCHEMA_HEADERS : NON_SCHEMA_HEADERS;
final List<String> row = new ArrayList<>(4);
row.add(topicDescription.getName());
row.add(topicDescription.getKafkaTopic());
row.add(format);
if (supportsSchema) {
row.add(topicDescription.getSchemaString());
}
return new Builder().withColumnHeaders(headings).withRow(row).build();
}
use of io.confluent.ksql.cli.console.table.Table.Builder in project ksql by confluentinc.
the class Console method printOverriddenProperties.
private void printOverriddenProperties(final QueryDescription queryDescription) {
final Map<String, Object> overriddenProperties = queryDescription.getOverriddenProperties();
if (overriddenProperties.isEmpty()) {
return;
}
final List<List<String>> rows = overriddenProperties.entrySet().stream().sorted(Entry.comparingByKey()).map(prop -> Arrays.asList(prop.getKey(), Objects.toString(prop.getValue()))).collect(Collectors.toList());
new Builder().withColumnHeaders("Property", "Value").withRows(rows).withHeaderLine(String.format("%n%-20s%n%-20s", "Overridden Properties", "---------------------")).build().print(this);
}
Aggregations