Search in sources :

Example 1 with SourceDescriptionEntity

use of io.confluent.ksql.rest.entity.SourceDescriptionEntity in project ksql by confluentinc.

the class ClientTest method shouldSendSessionVariablesWithDescribeSource.

@Test
public void shouldSendSessionVariablesWithDescribeSource() throws Exception {
    // Given
    javaClient.define("a", "a");
    final io.confluent.ksql.rest.entity.SourceDescription sd = new io.confluent.ksql.rest.entity.SourceDescription("name", Optional.of(WindowType.TUMBLING), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), "TABLE", "", "", "", false, "KAFKA", "JSON", "topic", 4, 1, "sql", Collections.emptyList(), ImmutableList.of("s1", "s2"));
    final SourceDescriptionEntity entity = new SourceDescriptionEntity("describe source;", sd, Collections.emptyList());
    testEndpoints.setKsqlEndpointResponse(Collections.singletonList(entity));
    // When
    javaClient.describeSource("source").get();
    // Then
    assertThat(testEndpoints.getLastSessionVariables(), is(new JsonObject().put("a", "a")));
}
Also used : SourceDescriptionEntity(io.confluent.ksql.rest.entity.SourceDescriptionEntity) JsonObject(io.vertx.core.json.JsonObject) BaseApiTest(io.confluent.ksql.api.BaseApiTest) Test(org.junit.Test)

Example 2 with SourceDescriptionEntity

use of io.confluent.ksql.rest.entity.SourceDescriptionEntity in project ksql by confluentinc.

the class ListSourceExecutor method columns.

public static StatementExecutorResponse columns(final ConfiguredStatement<ShowColumns> statement, final SessionProperties sessionProperties, final KsqlExecutionContext executionContext, final ServiceContext serviceContext) {
    final ShowColumns showColumns = statement.getStatement();
    final SourceDescriptionWithWarnings descriptionWithWarnings = describeSource(statement.getSessionConfig().getConfig(false), executionContext, serviceContext, showColumns.getTable(), showColumns.isExtended(), statement, sessionProperties, ImmutableList.of());
    return StatementExecutorResponse.handled(Optional.of(new SourceDescriptionEntity(statement.getStatementText(), descriptionWithWarnings.description, descriptionWithWarnings.warnings)));
}
Also used : ShowColumns(io.confluent.ksql.parser.tree.ShowColumns) SourceDescriptionEntity(io.confluent.ksql.rest.entity.SourceDescriptionEntity)

Example 3 with SourceDescriptionEntity

use of io.confluent.ksql.rest.entity.SourceDescriptionEntity in project ksql by confluentinc.

the class MigrationsTest method describeSource.

private static SourceDescription describeSource(final String name) {
    final List<KsqlEntity> entities = assertThatEventually(() -> makeKsqlRequest("DESCRIBE " + name + ";"), hasSize(1));
    assertThat(entities.get(0), instanceOf(SourceDescriptionEntity.class));
    SourceDescriptionEntity entity = (SourceDescriptionEntity) entities.get(0);
    return entity.getSourceDescription();
}
Also used : SourceDescriptionEntity(io.confluent.ksql.rest.entity.SourceDescriptionEntity) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity)

Example 4 with SourceDescriptionEntity

use of io.confluent.ksql.rest.entity.SourceDescriptionEntity in project ksql by confluentinc.

the class ConsoleTest method shouldPrintTopicDescribeExtended.

@Test
public void shouldPrintTopicDescribeExtended() {
    // Given:
    final List<RunningQuery> readQueries = ImmutableList.of(new RunningQuery("read query", ImmutableSet.of("sink1"), ImmutableSet.of("sink1 topic"), new QueryId("readId"), queryStatusCount, KsqlConstants.KsqlQueryType.PERSISTENT));
    final List<RunningQuery> writeQueries = ImmutableList.of(new RunningQuery("write query", ImmutableSet.of("sink2"), ImmutableSet.of("sink2 topic"), new QueryId("writeId"), queryStatusCount, KsqlConstants.KsqlQueryType.PERSISTENT));
    final KsqlEntityList entityList = new KsqlEntityList(ImmutableList.of(new SourceDescriptionEntity("e", new SourceDescription("TestSource", Optional.empty(), readQueries, writeQueries, buildTestSchema(SqlTypes.STRING), DataSourceType.KTABLE.getKsqlType(), "2000-01-01", "stats", "errors", true, "json", "avro", "kafka-topic", 2, 1, "sql statement text", ImmutableList.of(new QueryOffsetSummary("consumer1", ImmutableList.of(new QueryTopicOffsetSummary("kafka-topic", ImmutableList.of(new ConsumerPartitionOffsets(0, 100, 900, 800), new ConsumerPartitionOffsets(1, 50, 900, 900))), new QueryTopicOffsetSummary("kafka-topic-2", ImmutableList.of(new ConsumerPartitionOffsets(0, 0, 90, 80), new ConsumerPartitionOffsets(1, 10, 90, 90))))), new QueryOffsetSummary("consumer2", ImmutableList.of())), ImmutableList.of("S1", "S2")), Collections.emptyList())));
    // When:
    console.printKsqlEntityList(entityList);
    // Then:
    final String output = terminal.getOutputString();
    Approvals.verify(output, approvalOptions);
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) RunningQuery(io.confluent.ksql.rest.entity.RunningQuery) ConsumerPartitionOffsets(io.confluent.ksql.rest.entity.ConsumerPartitionOffsets) QueryId(io.confluent.ksql.query.QueryId) QueryOffsetSummary(io.confluent.ksql.rest.entity.QueryOffsetSummary) SourceDescriptionEntity(io.confluent.ksql.rest.entity.SourceDescriptionEntity) QueryTopicOffsetSummary(io.confluent.ksql.rest.entity.QueryTopicOffsetSummary) Matchers.containsString(org.hamcrest.Matchers.containsString) SourceDescription(io.confluent.ksql.rest.entity.SourceDescription) Test(org.junit.Test)

Example 5 with SourceDescriptionEntity

use of io.confluent.ksql.rest.entity.SourceDescriptionEntity in project ksql by confluentinc.

the class ConsoleTest method testPrintSourceDescriptionWithExtractedHeader.

@Test
public void testPrintSourceDescriptionWithExtractedHeader() {
    // Given:
    final List<FieldInfo> fields = buildTestSchema(Optional.of("abc"), SqlTypes.BOOLEAN, SqlTypes.INTEGER, SqlTypes.BIGINT, SqlTypes.DOUBLE, SqlTypes.STRING, SqlTypes.array(SqlTypes.STRING), SqlTypes.map(SqlTypes.STRING, SqlTypes.BIGINT), SqlTypes.struct().field("a", SqlTypes.DOUBLE).build());
    final List<RunningQuery> readQueries = ImmutableList.of(new RunningQuery("read query", ImmutableSet.of("sink1"), ImmutableSet.of("sink1 topic"), new QueryId("readId"), queryStatusCount, KsqlConstants.KsqlQueryType.PERSISTENT));
    final List<RunningQuery> writeQueries = ImmutableList.of(new RunningQuery("write query", ImmutableSet.of("sink2"), ImmutableSet.of("sink2 topic"), new QueryId("writeId"), queryStatusCount, KsqlConstants.KsqlQueryType.PERSISTENT));
    final KsqlEntityList entityList = new KsqlEntityList(ImmutableList.of(new SourceDescriptionEntity("some sql", buildSourceDescription(readQueries, writeQueries, fields, false), Collections.emptyList())));
    // When:
    console.printKsqlEntityList(entityList);
    // Then:
    final String output = terminal.getOutputString();
    Approvals.verify(output, approvalOptions);
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) RunningQuery(io.confluent.ksql.rest.entity.RunningQuery) QueryId(io.confluent.ksql.query.QueryId) SourceDescriptionEntity(io.confluent.ksql.rest.entity.SourceDescriptionEntity) Matchers.containsString(org.hamcrest.Matchers.containsString) FieldInfo(io.confluent.ksql.rest.entity.FieldInfo) Test(org.junit.Test)

Aggregations

SourceDescriptionEntity (io.confluent.ksql.rest.entity.SourceDescriptionEntity)14 Test (org.junit.Test)12 RunningQuery (io.confluent.ksql.rest.entity.RunningQuery)8 QueryId (io.confluent.ksql.query.QueryId)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 FieldInfo (io.confluent.ksql.rest.entity.FieldInfo)5 KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)5 BaseApiTest (io.confluent.ksql.api.BaseApiTest)3 MetricCollectors (io.confluent.ksql.metrics.MetricCollectors)3 ShowColumns (io.confluent.ksql.parser.tree.ShowColumns)3 KsqlEntity (io.confluent.ksql.rest.entity.KsqlEntity)3 KsqlWarning (io.confluent.ksql.rest.entity.KsqlWarning)2 QueryStatusCount (io.confluent.ksql.rest.entity.QueryStatusCount)2 SourceDescription (io.confluent.ksql.rest.entity.SourceDescription)2 ExecuteResult (io.confluent.ksql.KsqlExecutionContext.ExecuteResult)1 KsqlClientException (io.confluent.ksql.api.client.exception.KsqlClientException)1 KsqlException (io.confluent.ksql.api.client.exception.KsqlException)1 KsqlApiException (io.confluent.ksql.api.server.KsqlApiException)1 KafkaResponseGetFailedException (io.confluent.ksql.exception.KafkaResponseGetFailedException)1 DataSource (io.confluent.ksql.metastore.model.DataSource)1