Search in sources :

Example 1 with KsqlTopic

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();
}
Also used : KsqlWindowExpression(io.confluent.ksql.execution.windows.KsqlWindowExpression) KsqlTopic(io.confluent.ksql.execution.ddl.commands.KsqlTopic) WindowInfo(io.confluent.ksql.serde.WindowInfo)

Example 2 with KsqlTopic

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);
}
Also used : KsqlTopic(io.confluent.ksql.execution.ddl.commands.KsqlTopic)

Example 3 with 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));
}
Also used : SchemaKTable(io.confluent.ksql.structured.SchemaKTable) KsqlTable(io.confluent.ksql.metastore.model.KsqlTable) Matchers.containsString(org.hamcrest.Matchers.containsString) KsqlTopic(io.confluent.ksql.execution.ddl.commands.KsqlTopic) Test(org.junit.Test)

Example 4 with KsqlTopic

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);
}
Also used : ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) KsqlStream(io.confluent.ksql.metastore.model.KsqlStream) CreateTable(io.confluent.ksql.parser.tree.CreateTable) KsqlTable(io.confluent.ksql.metastore.model.KsqlTable) DropTable(io.confluent.ksql.parser.tree.DropTable) Table(io.confluent.ksql.parser.tree.Table) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) KsqlTable(io.confluent.ksql.metastore.model.KsqlTable) StringContains.containsString(org.hamcrest.core.StringContains.containsString) JoinOn(io.confluent.ksql.parser.tree.JoinOn) AliasedRelation(io.confluent.ksql.parser.tree.AliasedRelation) KsqlTopic(io.confluent.ksql.execution.ddl.commands.KsqlTopic) Before(org.junit.Before)

Example 5 with KsqlTopic

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()));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) KsqlTopic(io.confluent.ksql.execution.ddl.commands.KsqlTopic) DataSource(io.confluent.ksql.metastore.model.DataSource)

Aggregations

KsqlTopic (io.confluent.ksql.execution.ddl.commands.KsqlTopic)33 DataSource (io.confluent.ksql.metastore.model.DataSource)10 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)10 KsqlStream (io.confluent.ksql.metastore.model.KsqlStream)7 KeyFormat (io.confluent.ksql.serde.KeyFormat)6 Test (org.junit.Test)6 MetaStoreImpl (io.confluent.ksql.metastore.MetaStoreImpl)5 KsqlConfig (io.confluent.ksql.util.KsqlConfig)5 Before (org.junit.Before)5 KsqlTable (io.confluent.ksql.metastore.model.KsqlTable)4 KsqlStructuredDataOutputNode (io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 InternalFunctionRegistry (io.confluent.ksql.function.InternalFunctionRegistry)3 ValueFormat (io.confluent.ksql.serde.ValueFormat)3 PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 CreateTableCommand (io.confluent.ksql.execution.ddl.commands.CreateTableCommand)2 RuntimeBuildContext (io.confluent.ksql.execution.runtime.RuntimeBuildContext)2 MutableMetaStore (io.confluent.ksql.metastore.MutableMetaStore)2