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);
}
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);
}
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);
}
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")));
}
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));
}
Aggregations