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