use of io.confluent.ksql.rest.entity.FieldInfo in project ksql by confluentinc.
the class EntityUtilTest method shouldSupportRowTimeAndKeyInValueSchema.
@Test
public void shouldSupportRowTimeAndKeyInValueSchema() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().valueColumn(ColumnName.of("ROWKEY"), SqlTypes.STRING).valueColumn(ColumnName.of("ROWTIME"), SqlTypes.INTEGER).valueColumn(ColumnName.of("field1"), SqlTypes.INTEGER).build();
// When:
final List<FieldInfo> fields = EntityUtil.buildSourceSchemaEntity(schema);
// Then:
assertThat(fields, hasSize(3));
assertThat(fields.get(0).getName(), equalTo("ROWKEY"));
assertThat(fields.get(0).getType(), equalTo(Optional.empty()));
assertThat(fields.get(1).getName(), equalTo("ROWTIME"));
assertThat(fields.get(1).getType(), equalTo(Optional.empty()));
}
use of io.confluent.ksql.rest.entity.FieldInfo in project ksql by confluentinc.
the class ConsoleTest method buildSourceDescription.
private SourceDescription buildSourceDescription(final List<RunningQuery> readQueries, final List<RunningQuery> writeQueries, final List<FieldInfo> fields, final boolean withClusterStats) {
final Stat STAT = new Stat("TEST", 0, 1596644936314L);
final Stat ERROR_STAT = new Stat("ERROR", 0, 1596644936314L);
List<QueryHostStat> statistics = IntStream.range(1, 5).boxed().map((i) -> new KsqlHostInfoEntity("host" + i, 8000 + i)).map((host) -> QueryHostStat.fromStat(STAT, host)).collect(Collectors.toList());
List<QueryHostStat> errors = IntStream.range(1, 5).boxed().map((i) -> new KsqlHostInfoEntity("host" + i, 8000 + i)).map((host) -> QueryHostStat.fromStat(ERROR_STAT, host)).collect(Collectors.toList());
return new SourceDescription("TestSource", Optional.empty(), readQueries, writeQueries, fields, DataSourceType.KTABLE.getKsqlType(), "2000-01-01", "stats", "errors", true, "kafka", "avro", "kafka-topic", 1, 1, "sql statement", Collections.emptyList(), Collections.emptyList(), withClusterStats ? statistics : ImmutableList.of(), withClusterStats ? errors : ImmutableList.of());
}
use of io.confluent.ksql.rest.entity.FieldInfo 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);
}
use of io.confluent.ksql.rest.entity.FieldInfo 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.FieldInfo 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);
}
Aggregations