use of io.confluent.ksql.rest.entity.QueryDescription in project ksql by confluentinc.
the class ClientTest method shouldFailToExplainQueryViaExecuteStatement.
@Test
public void shouldFailToExplainQueryViaExecuteStatement() {
// Given
final QueryDescriptionEntity entity = new QueryDescriptionEntity("explain query;", new QueryDescription(new QueryId("id"), "sql", Optional.empty(), Collections.emptyList(), Collections.emptySet(), Collections.emptySet(), "topology", "executionPlan", Collections.emptyMap(), Collections.emptyMap(), KsqlQueryType.PERSISTENT, Collections.emptyList(), Collections.emptySet(), "consumerGroupId"));
testEndpoints.setKsqlEndpointResponse(Collections.singletonList(entity));
// When
final Exception e = assertThrows(// thrown from .get() when the future completes exceptionally
ExecutionException.class, () -> javaClient.executeStatement("explain query;").get());
// Then
assertThat(e.getCause(), instanceOf(KsqlClientException.class));
assertThat(e.getCause().getMessage(), containsString(EXECUTE_STATEMENT_USAGE_DOC));
assertThat(e.getCause().getMessage(), containsString("does not currently support 'EXPLAIN <QUERY_ID>' statements"));
}
use of io.confluent.ksql.rest.entity.QueryDescription in project ksql by confluentinc.
the class ListQueriesExecutor method mergeExtended.
private static Map<QueryId, QueryDescription> mergeExtended(final Map<QueryId, QueryDescription> allResults, final Pair<Map<HostInfo, KsqlEntity>, Set<HostInfo>> remoteResults) {
final List<QueryDescription> remoteQueryDescriptions = remoteResults.getLeft().values().stream().map(QueryDescriptionList.class::cast).map(QueryDescriptionList::getQueryDescriptions).flatMap(List::stream).collect(Collectors.toList());
for (QueryDescription q : remoteQueryDescriptions) {
final QueryId queryId = q.getId();
// and the streams metadata task set
if (allResults.containsKey(queryId)) {
for (Map.Entry<KsqlHostInfoEntity, KsqlQueryStatus> entry : q.getKsqlHostQueryStatus().entrySet()) {
allResults.get(queryId).updateKsqlHostQueryStatus(entry.getKey(), entry.getValue());
}
allResults.get(queryId).updateTaskMetadata(q.getTasksMetadata());
} else {
allResults.put(queryId, q);
}
}
final Set<HostInfo> unresponsiveRemoteHosts = remoteResults.getRight();
for (HostInfo hostInfo : unresponsiveRemoteHosts) {
for (QueryDescription queryDescription : allResults.values()) {
queryDescription.updateKsqlHostQueryStatus(new KsqlHostInfoEntity(hostInfo.host(), hostInfo.port()), KsqlQueryStatus.UNRESPONSIVE);
}
}
return allResults;
}
use of io.confluent.ksql.rest.entity.QueryDescription 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