use of io.confluent.ksql.metastore.model.KsqlStream in project ksql by confluentinc.
the class SqlFormatterTest method setUp.
@Before
public void setUp() {
final Table left = new Table(SourceName.of("left"));
final Table right = new Table(SourceName.of("right"));
final Table right2 = new Table(SourceName.of("right2"));
leftAlias = new AliasedRelation(left, SourceName.of("L"));
rightAlias = new AliasedRelation(right, SourceName.of("R"));
right2Alias = new AliasedRelation(right2, SourceName.of("R2"));
criteria = new JoinOn(new ComparisonExpression(ComparisonExpression.Type.EQUAL, new StringLiteral("left.col0"), new StringLiteral("right.col0")));
criteria2 = new JoinOn(new ComparisonExpression(ComparisonExpression.Type.EQUAL, new StringLiteral("left.col0"), new StringLiteral("right2.col0")));
metaStore = MetaStoreFixture.getNewMetaStore(mock(FunctionRegistry.class));
final KsqlTopic ksqlTopicOrders = new KsqlTopic("orders_topic", KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()), ValueFormat.of(FormatInfo.of(FormatFactory.JSON.name()), SerdeFeatures.of()));
final KsqlStream<?> ksqlStreamOrders = new KsqlStream<>("sqlexpression", SourceName.of("ADDRESS"), ORDERS_SCHEMA, Optional.empty(), false, ksqlTopicOrders, false);
metaStore.putSource(ksqlStreamOrders, false);
final KsqlTopic ksqlTopicItems = new KsqlTopic("item_topic", KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()), ValueFormat.of(FormatInfo.of(FormatFactory.JSON.name()), SerdeFeatures.of()));
final KsqlTable<String> ksqlTableOrders = new KsqlTable<>("sqlexpression", SourceName.of("ITEMID"), ITEM_INFO_SCHEMA, Optional.empty(), false, ksqlTopicItems, false);
metaStore.putSource(ksqlTableOrders, false);
final KsqlTable<String> ksqlTableTable = new KsqlTable<>("sqlexpression", SourceName.of("TABLE"), TABLE_SCHEMA, Optional.empty(), false, ksqlTopicItems, false);
metaStore.putSource(ksqlTableTable, false);
}
use of io.confluent.ksql.metastore.model.KsqlStream in project ksql by confluentinc.
the class ListSourceExecutor method streams.
public static StatementExecutorResponse streams(final ConfiguredStatement<ListStreams> statement, final SessionProperties sessionProperties, final KsqlExecutionContext executionContext, final ServiceContext serviceContext) {
final List<KsqlStream<?>> ksqlStreams = getSpecificStreams(executionContext);
final ListStreams listStreams = statement.getStatement();
if (listStreams.getShowExtended()) {
return StatementExecutorResponse.handled(sourceDescriptionList(statement, sessionProperties, executionContext, serviceContext, ksqlStreams, listStreams.getShowExtended()));
}
return StatementExecutorResponse.handled(Optional.of(new StreamsList(statement.getStatementText(), ksqlStreams.stream().map(ListSourceExecutor::sourceSteam).collect(Collectors.toList()))));
}
use of io.confluent.ksql.metastore.model.KsqlStream in project ksql by confluentinc.
the class SchemaRegisterInjectorTest method setUp.
@Before
public void setUp() throws IOException, RestClientException {
metaStore = new MetaStoreImpl(new InternalFunctionRegistry());
config = new KsqlConfig(ImmutableMap.of(KsqlConfig.SCHEMA_REGISTRY_URL_PROPERTY, "foo:8081"));
injector = new SchemaRegisterInjector(executionContext, serviceContext);
when(serviceContext.getSchemaRegistryClient()).thenReturn(schemaRegistryClient);
when(serviceContext.getTopicClient()).thenReturn(topicClient);
when(serviceContext.getConsumerGroupClient()).thenReturn(consumerGroupClient);
when(executionContext.createSandbox(any())).thenReturn(executionSandbox);
when(keyFeatures.enabled(SerdeFeature.UNWRAP_SINGLES)).thenReturn(true);
when(ddlCommand.getSchema()).thenReturn(SCHEMA);
when(ddlCommand.getTopicName()).thenReturn("SINK");
when(ddlCommand.getFormats()).thenReturn(formats);
when(formats.getKeyFormat()).thenReturn(FormatInfo.of(FormatFactory.AVRO.name()));
when(formats.getKeyFeatures()).thenReturn(keyFeatures);
when(formats.getValueFormat()).thenReturn(FormatInfo.of(FormatFactory.AVRO.name()));
when(formats.getValueFeatures()).thenReturn(valFeatures);
when(schemaRegistryClient.getLatestSchemaMetadata(any())).thenThrow(new RestClientException("foo", 404, SchemaRegistryUtil.SUBJECT_NOT_FOUND_ERROR_CODE));
final KsqlTopic sourceTopic = new KsqlTopic("source", KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()), ValueFormat.of(FormatInfo.of(FormatFactory.JSON.name()), valFeatures));
final KsqlStream<?> source = new KsqlStream<>("", SourceName.of("SOURCE"), SCHEMA, Optional.empty(), false, sourceTopic, false);
metaStore.putSource(source, false);
}
use of io.confluent.ksql.metastore.model.KsqlStream in project ksql by confluentinc.
the class SourceDescriptionFactoryTest method buildDataSource.
private static DataSource buildDataSource(final String kafkaTopicName, final Optional<TimestampColumn> timestampColumn) {
final LogicalSchema schema = LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(ColumnName.of("field0"), SqlTypes.INTEGER).build();
final KsqlTopic topic = new KsqlTopic(kafkaTopicName, KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()), ValueFormat.of(FormatInfo.of(FormatFactory.JSON.name()), SerdeFeatures.of()));
return new KsqlStream<>("query", SourceName.of("stream"), schema, timestampColumn, false, topic, false);
}
use of io.confluent.ksql.metastore.model.KsqlStream in project ksql by confluentinc.
the class ListSourceExecutorTest method shouldShowStreams.
@Test
public void shouldShowStreams() {
// Given:
final KsqlStream<?> stream1 = engine.givenSource(DataSourceType.KSTREAM, "stream1");
final KsqlStream<?> stream2 = engine.givenSource(DataSourceType.KSTREAM, "stream2");
engine.givenSource(DataSourceType.KTABLE, "table");
// When:
final StreamsList descriptionList = (StreamsList) CUSTOM_EXECUTORS.listStreams().execute((ConfiguredStatement<ListStreams>) engine.configure("SHOW STREAMS;"), SESSION_PROPERTIES, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(descriptionList.getStreams(), containsInAnyOrder(new SourceInfo.Stream(stream1.getName().toString(FormatOptions.noEscape()), stream1.getKafkaTopicName(), stream1.getKsqlTopic().getKeyFormat().getFormat(), stream1.getKsqlTopic().getValueFormat().getFormat(), stream1.getKsqlTopic().getKeyFormat().isWindowed()), new SourceInfo.Stream(stream2.getName().toString(FormatOptions.noEscape()), stream2.getKafkaTopicName(), stream2.getKsqlTopic().getKeyFormat().getFormat(), stream2.getKsqlTopic().getValueFormat().getFormat(), stream1.getKsqlTopic().getKeyFormat().isWindowed())));
}
Aggregations