Search in sources :

Example 6 with SourceDescriptionEntity

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

the class ConsoleTest method testPrintSourceDescriptionWithClusterStats.

@Test
public void testPrintSourceDescriptionWithClusterStats() {
    // Given:
    final List<FieldInfo> fields = buildTestSchema(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, true), 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)

Example 7 with SourceDescriptionEntity

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

the class ConsoleTest method testPrintSourceDescriptionWithHeaders.

@Test
public void testPrintSourceDescriptionWithHeaders() {
    // Given:
    final List<FieldInfo> fields = buildTestSchema(Optional.empty(), 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)

Example 8 with SourceDescriptionEntity

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

the class ConsoleTest method testPrintSourceDescription.

@Test
public void testPrintSourceDescription() {
    // Given:
    final List<FieldInfo> fields = buildTestSchema(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)

Example 9 with SourceDescriptionEntity

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

the class ListSourceExecutorTest method shouldAddWarningOnClientExceptionForDescription.

@Test
public void shouldAddWarningOnClientExceptionForDescription() {
    // Given:
    final KsqlStream<?> stream1 = engine.givenSource(DataSourceType.KSTREAM, "STREAM1");
    final ServiceContext serviceContext = engine.getServiceContext();
    serviceContext.getTopicClient().deleteTopics(ImmutableList.of("STREAM1"));
    // When:
    final KsqlEntity entity = CUSTOM_EXECUTORS.showColumns().execute((ConfiguredStatement<ShowColumns>) engine.configure("DESCRIBE STREAM1 EXTENDED;"), SESSION_PROPERTIES, engine.getEngine(), serviceContext).getEntity().orElseThrow(IllegalStateException::new);
    // Then:
    assertThat(entity, instanceOf(SourceDescriptionEntity.class));
    final SourceDescriptionEntity description = (SourceDescriptionEntity) entity;
    assertThat(description.getSourceDescription(), equalTo(SourceDescriptionFactory.create(stream1, true, ImmutableList.of(), ImmutableList.of(), Optional.empty(), ImmutableList.of(), ImmutableList.of(), new MetricCollectors())));
    assertThat(description.getWarnings(), contains(new KsqlWarning("Error from Kafka: unknown topic: STREAM1")));
}
Also used : ServiceContext(io.confluent.ksql.services.ServiceContext) TestServiceContext(io.confluent.ksql.services.TestServiceContext) ShowColumns(io.confluent.ksql.parser.tree.ShowColumns) SourceDescriptionEntity(io.confluent.ksql.rest.entity.SourceDescriptionEntity) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) KsqlWarning(io.confluent.ksql.rest.entity.KsqlWarning) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) Test(org.junit.Test)

Example 10 with SourceDescriptionEntity

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

the class KsqlResourceTest method shouldDescribeStatement.

@Test
public void shouldDescribeStatement() {
    // Given:
    final List<RunningQuery> queries = createRunningQueries("CREATE STREAM described_stream AS SELECT * FROM test_stream;" + "CREATE STREAM down_stream AS SELECT * FROM described_stream;", emptyMap());
    // When:
    final SourceDescriptionEntity description = makeSingleRequest("DESCRIBE DESCRIBED_STREAM;", SourceDescriptionEntity.class);
    // Then:
    final SourceDescription expectedDescription = SourceDescriptionFactory.create(ksqlEngine.getMetaStore().getSource(SourceName.of("DESCRIBED_STREAM")), false, Collections.singletonList(queries.get(1)), Collections.singletonList(queries.get(0)), Optional.empty(), Collections.emptyList(), Collections.emptyList(), new MetricCollectors());
    assertThat(description.getSourceDescription(), is(expectedDescription));
}
Also used : RunningQuery(io.confluent.ksql.rest.entity.RunningQuery) SourceDescriptionEntity(io.confluent.ksql.rest.entity.SourceDescriptionEntity) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) SourceDescription(io.confluent.ksql.rest.entity.SourceDescription) 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