use of io.confluent.ksql.execution.ddl.commands.KsqlTopic in project ksql by confluentinc.
the class LogicalPlanner method getWindowInfo.
private Optional<WindowInfo> getWindowInfo() {
final KsqlTopic srcTopic = analysis.getFrom().getDataSource().getKsqlTopic();
final Optional<WindowInfo> explicitWindowInfo = analysis.getWindowExpression().map(WindowExpression::getKsqlWindowExpression).map(KsqlWindowExpression::getWindowInfo);
return explicitWindowInfo.isPresent() ? explicitWindowInfo : srcTopic.getKeyFormat().getWindowInfo();
}
use of io.confluent.ksql.execution.ddl.commands.KsqlTopic in project ksql by confluentinc.
the class JoinNodeTest method setUpSource.
private static void setUpSource(final PlanNode node, final ValueFormat valueFormat, final DataSourceNode dataSourceNode, final DataSource dataSource) {
when(dataSourceNode.getDataSource()).thenReturn(dataSource);
when(node.getLeftmostSourceNode()).thenReturn(dataSourceNode);
when(node.getSources()).thenReturn(ImmutableList.of(dataSourceNode));
final KsqlTopic ksqlTopic = mock(KsqlTopic.class);
when(ksqlTopic.getValueFormat()).thenReturn(valueFormat);
when(dataSource.getKsqlTopic()).thenReturn(ksqlTopic);
}
use of io.confluent.ksql.execution.ddl.commands.KsqlTopic in project ksql by confluentinc.
the class DataSourceNodeTest method shouldBuildSchemaKTableWhenKTableSource.
@Test
public void shouldBuildSchemaKTableWhenKTableSource() {
// Given:
final KsqlTable<String> table = new KsqlTable<>("sqlExpression", SourceName.of("datasource"), REAL_SCHEMA, Optional.of(TIMESTAMP_COLUMN), false, new KsqlTopic("topic2", KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()), ValueFormat.of(FormatInfo.of(FormatFactory.JSON.name()), SerdeFeatures.of())), false);
node = new DataSourceNode(PLAN_NODE_ID, table, table.getName(), false, ksqlConfig);
// When:
final SchemaKStream<?> result = buildStream(node);
// Then:
assertThat(result.getClass(), equalTo(SchemaKTable.class));
}
use of io.confluent.ksql.execution.ddl.commands.KsqlTopic 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.execution.ddl.commands.KsqlTopic in project ksql by confluentinc.
the class ClusterTerminatorTest method givenSourceRegisteredWithTopic.
private void givenSourceRegisteredWithTopic(final Format format, final String kafkaTopicName, final boolean sink) {
final String sourceName = "SOURCE_" + kafkaTopicName;
final KsqlTopic topic = mock(KsqlTopic.class);
when(topic.getKafkaTopicName()).thenReturn(kafkaTopicName);
when(topic.getKeyFormat()).thenReturn(KeyFormat.of(FormatInfo.of(format.name()), SerdeFeatures.of(), Optional.empty()));
when(topic.getValueFormat()).thenReturn(ValueFormat.of(FormatInfo.of(format.name()), SerdeFeatures.of()));
final DataSource source = mock(DataSource.class);
when(source.getKafkaTopicName()).thenReturn(kafkaTopicName);
when(source.getKsqlTopic()).thenReturn(topic);
when(source.isCasTarget()).thenReturn(sink);
assertThat("topic already registered", dataSources.put(SourceName.of(sourceName), source), is(nullValue()));
}
Aggregations