use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.
the class KsqlResourceTest method shouldShowTablesExtended.
@Test
public void shouldShowTablesExtended() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(ColumnName.of("FIELD1"), SqlTypes.BOOLEAN).valueColumn(ColumnName.of("FIELD2"), SqlTypes.STRING).build();
givenSource(DataSourceType.KTABLE, "new_table", "new_topic", schema, ImmutableSet.of(SourceName.of("TEST_TABLE")));
// When:
final SourceDescriptionList descriptionList = makeSingleRequest("SHOW TABLES EXTENDED;", SourceDescriptionList.class);
// Then:
assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(ksqlEngine.getMetaStore().getSource(SourceName.of("TEST_TABLE")), true, Collections.emptyList(), Collections.emptyList(), Optional.of(kafkaTopicClient.describeTopic("KAFKA_TOPIC_1")), Collections.emptyList(), ImmutableList.of("new_table"), new MetricCollectors()), SourceDescriptionFactory.create(ksqlEngine.getMetaStore().getSource(SourceName.of("new_table")), true, Collections.emptyList(), Collections.emptyList(), Optional.of(kafkaTopicClient.describeTopic("new_topic")), Collections.emptyList(), Collections.emptyList(), new MetricCollectors())));
}
use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.
the class KsqlResourceTest method shouldDescribeTables.
@Test
public void shouldDescribeTables() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(ColumnName.of("FIELD1"), SqlTypes.BOOLEAN).valueColumn(ColumnName.of("FIELD2"), SqlTypes.STRING).build();
givenSource(DataSourceType.KTABLE, "new_table", "new_topic", schema, ImmutableSet.of(SourceName.of("TEST_TABLE")));
// When:
final SourceDescriptionList descriptionList = makeSingleRequest("DESCRIBE TABLES;", SourceDescriptionList.class);
// Then:
assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(ksqlEngine.getMetaStore().getSource(SourceName.of("TEST_TABLE")), false, Collections.emptyList(), Collections.emptyList(), Optional.of(kafkaTopicClient.describeTopic("KAFKA_TOPIC_1")), Collections.emptyList(), ImmutableList.of("new_table"), new MetricCollectors()), SourceDescriptionFactory.create(ksqlEngine.getMetaStore().getSource(SourceName.of("new_table")), false, Collections.emptyList(), Collections.emptyList(), Optional.of(kafkaTopicClient.describeTopic("new_topic")), Collections.emptyList(), Collections.emptyList(), new MetricCollectors())));
}
use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.
the class KsqlResourceTest method shouldDescribeStreams.
@Test
public void shouldDescribeStreams() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(ColumnName.of("FIELD1"), SqlTypes.BOOLEAN).valueColumn(ColumnName.of("FIELD2"), SqlTypes.STRING).build();
givenSource(DataSourceType.KSTREAM, "new_stream", "new_topic", schema);
// When:
final SourceDescriptionList descriptionList = makeSingleRequest("DESCRIBE STREAMS;", SourceDescriptionList.class);
// Then:
assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(ksqlEngine.getMetaStore().getSource(SourceName.of("TEST_STREAM")), false, Collections.emptyList(), Collections.emptyList(), Optional.of(kafkaTopicClient.describeTopic("KAFKA_TOPIC_2")), Collections.emptyList(), Collections.emptyList(), new MetricCollectors()), SourceDescriptionFactory.create(ksqlEngine.getMetaStore().getSource(SourceName.of("new_stream")), false, Collections.emptyList(), Collections.emptyList(), Optional.of(kafkaTopicClient.describeTopic("new_topic")), Collections.emptyList(), Collections.emptyList(), new MetricCollectors())));
}
use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.
the class QueryStreamWriterTest method setUp.
@Before
public void setUp() {
objectMapper = ApiJsonMapper.INSTANCE.get();
final LogicalSchema schema = LogicalSchema.builder().keyColumn(ColumnName.of("keyCol"), SqlTypes.STRING).valueColumn(ColumnName.of("col1"), SqlTypes.STRING).build();
when(queryMetadata.getQueryId()).thenReturn(new QueryId("id"));
when(queryMetadata.getRowQueue()).thenReturn(rowQueue);
when(queryMetadata.getLogicalSchema()).thenReturn(schema);
when(queryMetadata.isRunning()).thenReturn(true);
when(queryMetadata.getResultType()).thenReturn(ResultType.STREAM);
}
use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.
the class StepSchemaResolverTest method shouldResolveSchemaForTableSelectWithColumnNames.
@Test
public void shouldResolveSchemaForTableSelectWithColumnNames() {
// Given:
final TableSelect<?> step = new TableSelect<>(PROPERTIES, tableSource, ImmutableList.of(ColumnName.of("NEW_KEY")), ImmutableList.of(add("JUICE", "ORANGE", "APPLE"), ref("PLANTAIN", "BANANA"), ref("CITRUS", "ORANGE")), internalFormats);
// When:
final LogicalSchema result = resolver.resolve(step, SCHEMA);
// Then:
assertThat(result, is(LogicalSchema.builder().keyColumn(ColumnName.of("NEW_KEY"), SqlTypes.INTEGER).valueColumn(ColumnName.of("JUICE"), SqlTypes.BIGINT).valueColumn(ColumnName.of("PLANTAIN"), SqlTypes.STRING).valueColumn(ColumnName.of("CITRUS"), SqlTypes.INTEGER).build()));
}
Aggregations