Search in sources :

Example 6 with QueryDescription

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"));
}
Also used : QueryDescriptionEntity(io.confluent.ksql.rest.entity.QueryDescriptionEntity) KsqlClientException(io.confluent.ksql.api.client.exception.KsqlClientException) QueryId(io.confluent.ksql.query.QueryId) PushQueryId(io.confluent.ksql.rest.entity.PushQueryId) QueryDescription(io.confluent.ksql.rest.entity.QueryDescription) KafkaResponseGetFailedException(io.confluent.ksql.exception.KafkaResponseGetFailedException) KsqlClientException(io.confluent.ksql.api.client.exception.KsqlClientException) KsqlApiException(io.confluent.ksql.api.server.KsqlApiException) ExecutionException(java.util.concurrent.ExecutionException) ParseFailedException(io.confluent.ksql.parser.exception.ParseFailedException) KsqlException(io.confluent.ksql.api.client.exception.KsqlException) BaseApiTest(io.confluent.ksql.api.BaseApiTest) Test(org.junit.Test)

Example 7 with QueryDescription

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;
}
Also used : QueryId(io.confluent.ksql.query.QueryId) QueryDescriptionList(io.confluent.ksql.rest.entity.QueryDescriptionList) KsqlHostInfoEntity(io.confluent.ksql.rest.entity.KsqlHostInfoEntity) QueryDescription(io.confluent.ksql.rest.entity.QueryDescription) Map(java.util.Map) HostInfo(org.apache.kafka.streams.state.HostInfo) KsqlQueryStatus(io.confluent.ksql.util.KsqlConstants.KsqlQueryStatus)

Example 8 with QueryDescription

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);
}
Also used : Arrays(java.util.Arrays) Builder(io.confluent.ksql.cli.console.table.Table.Builder) StreamsList(io.confluent.ksql.rest.entity.StreamsList) PropertiesListTableBuilder(io.confluent.ksql.cli.console.table.builder.PropertiesListTableBuilder) RunningQuery(io.confluent.ksql.rest.entity.RunningQuery) OnOff(io.confluent.ksql.cli.console.CliConfig.OnOff) SourceDescription(io.confluent.ksql.rest.entity.SourceDescription) StringUtils(org.apache.commons.lang3.StringUtils) KsqlErrorMessage(io.confluent.ksql.rest.entity.KsqlErrorMessage) QueryHostStat(io.confluent.ksql.rest.entity.QueryHostStat) ConnectorList(io.confluent.ksql.rest.entity.ConnectorList) Map(java.util.Map) WindowType(io.confluent.ksql.model.WindowType) TablesListTableBuilder(io.confluent.ksql.cli.console.table.builder.TablesListTableBuilder) Path(java.nio.file.Path) PrintWriter(java.io.PrintWriter) TableBuilder(io.confluent.ksql.cli.console.table.builder.TableBuilder) TypeList(io.confluent.ksql.rest.entity.TypeList) ListVariablesTableBuilder(io.confluent.ksql.cli.console.table.builder.ListVariablesTableBuilder) StatusClosable(io.confluent.ksql.cli.console.KsqlTerminal.StatusClosable) Handler1(io.confluent.ksql.util.HandlerMaps.Handler1) ArgumentInfo(io.confluent.ksql.rest.entity.ArgumentInfo) ApiJsonMapper(io.confluent.ksql.rest.ApiJsonMapper) ZoneId(java.time.ZoneId) QueryDescription(io.confluent.ksql.rest.entity.QueryDescription) Stream(java.util.stream.Stream) TopicDescription(io.confluent.ksql.rest.entity.TopicDescription) KsqlException(io.confluent.ksql.util.KsqlException) TerminateQueryTableBuilder(io.confluent.ksql.cli.console.table.builder.TerminateQueryTableBuilder) DropConnectorEntity(io.confluent.ksql.rest.entity.DropConnectorEntity) StreamedRow(io.confluent.ksql.rest.entity.StreamedRow) TopicDescriptionTableBuilder(io.confluent.ksql.cli.console.table.builder.TopicDescriptionTableBuilder) FieldInfo(io.confluent.ksql.rest.entity.FieldInfo) FunctionDescriptionList(io.confluent.ksql.rest.entity.FunctionDescriptionList) Stat(io.confluent.ksql.metrics.TopicSensors.Stat) Supplier(java.util.function.Supplier) CmdLineUtil.splitByUnquotedWhitespace(io.confluent.ksql.util.CmdLineUtil.splitByUnquotedWhitespace) DropConnectorTableBuilder(io.confluent.ksql.cli.console.table.builder.DropConnectorTableBuilder) StringTokenizer(java.util.StringTokenizer) TypeListTableBuilder(io.confluent.ksql.cli.console.table.builder.TypeListTableBuilder) CliSpecificCommand(io.confluent.ksql.cli.console.cmd.CliSpecificCommand) IOException(java.io.IOException) File(java.io.File) Paths(java.nio.file.Paths) Signal(org.jline.terminal.Terminal.Signal) HandlerMaps(io.confluent.ksql.util.HandlerMaps) KsqlWarning(io.confluent.ksql.rest.entity.KsqlWarning) ErrorEntity(io.confluent.ksql.rest.entity.ErrorEntity) ConnectorPluginsList(io.confluent.ksql.rest.entity.ConnectorPluginsList) FunctionNameList(io.confluent.ksql.rest.entity.FunctionNameList) QueryOffsetSummary(io.confluent.ksql.rest.entity.QueryOffsetSummary) LoggerFactory(org.slf4j.LoggerFactory) Header(io.confluent.ksql.rest.entity.StreamedRow.Header) WarningEntityTableBuilder(io.confluent.ksql.cli.console.table.builder.WarningEntityTableBuilder) QueryTopicOffsetSummary(io.confluent.ksql.rest.entity.QueryTopicOffsetSummary) KafkaTopicsList(io.confluent.ksql.rest.entity.KafkaTopicsList) KafkaTopicsListExtended(io.confluent.ksql.rest.entity.KafkaTopicsListExtended) DataRow(io.confluent.ksql.rest.entity.StreamedRow.DataRow) CommandStatusTableBuilder(io.confluent.ksql.cli.console.table.builder.CommandStatusTableBuilder) ExecutionPlan(io.confluent.ksql.rest.entity.ExecutionPlan) StreamsListTableBuilder(io.confluent.ksql.cli.console.table.builder.StreamsListTableBuilder) Table(io.confluent.ksql.cli.console.table.Table) SourceDescriptionList(io.confluent.ksql.rest.entity.SourceDescriptionList) QueryDescriptionList(io.confluent.ksql.rest.entity.QueryDescriptionList) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ClassHandlerMap1(io.confluent.ksql.util.HandlerMaps.ClassHandlerMap1) QueriesTableBuilder(io.confluent.ksql.cli.console.table.builder.QueriesTableBuilder) ErrorEntityTableBuilder(io.confluent.ksql.cli.console.table.builder.ErrorEntityTableBuilder) FieldType(io.confluent.ksql.rest.entity.FieldInfo.FieldType) Streams(com.google.common.collect.Streams) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) List(java.util.List) CreateConnectorEntity(io.confluent.ksql.rest.entity.CreateConnectorEntity) FunctionInfo(io.confluent.ksql.rest.entity.FunctionInfo) ConnectorDescription(io.confluent.ksql.rest.entity.ConnectorDescription) Entry(java.util.Map.Entry) ConnectorInfoTableBuilder(io.confluent.ksql.cli.console.table.builder.ConnectorInfoTableBuilder) Optional(java.util.Optional) ExecutionPlanTableBuilder(io.confluent.ksql.cli.console.table.builder.ExecutionPlanTableBuilder) WarningEntity(io.confluent.ksql.rest.entity.WarningEntity) HistoryEntry(io.confluent.ksql.cli.console.KsqlTerminal.HistoryEntry) TerminateQueryEntity(io.confluent.ksql.rest.entity.TerminateQueryEntity) ConnectorPluginsListTableBuilder(io.confluent.ksql.cli.console.table.builder.ConnectorPluginsListTableBuilder) QueryDescriptionEntity(io.confluent.ksql.rest.entity.QueryDescriptionEntity) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) QueryError(io.confluent.ksql.query.QueryError) SignalHandler(org.jline.terminal.Terminal.SignalHandler) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) ImmutableList(com.google.common.collect.ImmutableList) Charset(java.nio.charset.Charset) ObjectUtils(org.apache.commons.lang3.ObjectUtils) SourceDescriptionEntity(io.confluent.ksql.rest.entity.SourceDescriptionEntity) KafkaTopicsListTableBuilder(io.confluent.ksql.cli.console.table.builder.KafkaTopicsListTableBuilder) Queries(io.confluent.ksql.rest.entity.Queries) TablesList(io.confluent.ksql.rest.entity.TablesList) VariablesList(io.confluent.ksql.rest.entity.VariablesList) CmdLineUtil(io.confluent.ksql.util.CmdLineUtil) TabularRow(io.confluent.ksql.util.TabularRow) Logger(org.slf4j.Logger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CommandStatusEntity(io.confluent.ksql.rest.entity.CommandStatusEntity) Maps(com.google.common.collect.Maps) ConfigException(org.apache.kafka.common.config.ConfigException) ConnectorListTableBuilder(io.confluent.ksql.cli.console.table.builder.ConnectorListTableBuilder) FunctionNameListTableBuilder(io.confluent.ksql.cli.console.table.builder.FunctionNameListTableBuilder) Closeable(java.io.Closeable) DateTimeFormatter(java.time.format.DateTimeFormatter) KsqlStatementErrorMessage(io.confluent.ksql.rest.entity.KsqlStatementErrorMessage) Comparator(java.util.Comparator) Collections(java.util.Collections) Builder(io.confluent.ksql.cli.console.table.Table.Builder) PropertiesListTableBuilder(io.confluent.ksql.cli.console.table.builder.PropertiesListTableBuilder) TablesListTableBuilder(io.confluent.ksql.cli.console.table.builder.TablesListTableBuilder) TableBuilder(io.confluent.ksql.cli.console.table.builder.TableBuilder) ListVariablesTableBuilder(io.confluent.ksql.cli.console.table.builder.ListVariablesTableBuilder) TerminateQueryTableBuilder(io.confluent.ksql.cli.console.table.builder.TerminateQueryTableBuilder) TopicDescriptionTableBuilder(io.confluent.ksql.cli.console.table.builder.TopicDescriptionTableBuilder) DropConnectorTableBuilder(io.confluent.ksql.cli.console.table.builder.DropConnectorTableBuilder) TypeListTableBuilder(io.confluent.ksql.cli.console.table.builder.TypeListTableBuilder) WarningEntityTableBuilder(io.confluent.ksql.cli.console.table.builder.WarningEntityTableBuilder) CommandStatusTableBuilder(io.confluent.ksql.cli.console.table.builder.CommandStatusTableBuilder) StreamsListTableBuilder(io.confluent.ksql.cli.console.table.builder.StreamsListTableBuilder) QueriesTableBuilder(io.confluent.ksql.cli.console.table.builder.QueriesTableBuilder) ErrorEntityTableBuilder(io.confluent.ksql.cli.console.table.builder.ErrorEntityTableBuilder) ConnectorInfoTableBuilder(io.confluent.ksql.cli.console.table.builder.ConnectorInfoTableBuilder) ExecutionPlanTableBuilder(io.confluent.ksql.cli.console.table.builder.ExecutionPlanTableBuilder) ConnectorPluginsListTableBuilder(io.confluent.ksql.cli.console.table.builder.ConnectorPluginsListTableBuilder) KafkaTopicsListTableBuilder(io.confluent.ksql.cli.console.table.builder.KafkaTopicsListTableBuilder) ConnectorListTableBuilder(io.confluent.ksql.cli.console.table.builder.ConnectorListTableBuilder) FunctionNameListTableBuilder(io.confluent.ksql.cli.console.table.builder.FunctionNameListTableBuilder) StreamsList(io.confluent.ksql.rest.entity.StreamsList) ConnectorList(io.confluent.ksql.rest.entity.ConnectorList) TypeList(io.confluent.ksql.rest.entity.TypeList) FunctionDescriptionList(io.confluent.ksql.rest.entity.FunctionDescriptionList) ConnectorPluginsList(io.confluent.ksql.rest.entity.ConnectorPluginsList) FunctionNameList(io.confluent.ksql.rest.entity.FunctionNameList) KafkaTopicsList(io.confluent.ksql.rest.entity.KafkaTopicsList) SourceDescriptionList(io.confluent.ksql.rest.entity.SourceDescriptionList) QueryDescriptionList(io.confluent.ksql.rest.entity.QueryDescriptionList) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) TablesList(io.confluent.ksql.rest.entity.TablesList) VariablesList(io.confluent.ksql.rest.entity.VariablesList)

Aggregations

QueryDescription (io.confluent.ksql.rest.entity.QueryDescription)8 QueryDescriptionList (io.confluent.ksql.rest.entity.QueryDescriptionList)5 QueryDescriptionEntity (io.confluent.ksql.rest.entity.QueryDescriptionEntity)4 QueryId (io.confluent.ksql.query.QueryId)3 KsqlHostInfoEntity (io.confluent.ksql.rest.entity.KsqlHostInfoEntity)3 Test (org.junit.Test)3 KsqlEngine (io.confluent.ksql.engine.KsqlEngine)2 ListQueries (io.confluent.ksql.parser.tree.ListQueries)2 KsqlEntity (io.confluent.ksql.rest.entity.KsqlEntity)2 StreamsTaskMetadata (io.confluent.ksql.rest.entity.StreamsTaskMetadata)2 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)2 KsqlQueryStatus (io.confluent.ksql.util.KsqlConstants.KsqlQueryStatus)2 PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)2 Map (java.util.Map)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Maps (com.google.common.collect.Maps)1 Streams (com.google.common.collect.Streams)1 BaseApiTest (io.confluent.ksql.api.BaseApiTest)1