use of io.confluent.ksql.structured.SchemaKStream in project ksql by confluentinc.
the class PhysicalPlanBuilder method buildPlanForBareQuery.
private QueryMetadata buildPlanForBareQuery(final QueuedSchemaKStream schemaKStream, final KsqlBareOutputNode bareOutputNode, final String serviceId, final String transientQueryPrefix, final String statement) {
final String applicationId = addTimeSuffix(getBareQueryApplicationId(serviceId, transientQueryPrefix));
KafkaStreams streams = buildStreams(builder, applicationId, ksqlConfig, overriddenStreamsProperties);
SchemaKStream sourceSchemaKstream = schemaKStream.getSourceSchemaKStreams().get(0);
return new QueuedQueryMetadata(statement, streams, bareOutputNode, schemaKStream.getExecutionPlan(""), schemaKStream.getQueue(), (sourceSchemaKstream instanceof SchemaKTable) ? DataSource.DataSourceType.KTABLE : DataSource.DataSourceType.KSTREAM, applicationId, kafkaTopicClient, builder.build());
}
use of io.confluent.ksql.structured.SchemaKStream in project ksql by confluentinc.
the class KsqlStructuredDataOutputNodeTest method shouldPartitionByFieldNameInPartitionByProperty.
@Test
public void shouldPartitionByFieldNameInPartitionByProperty() {
createOutputNode(Collections.singletonMap(DdlConfig.PARTITION_BY_PROPERTY, "field2"));
final SchemaKStream schemaKStream = buildStream();
final Field keyField = schemaKStream.getKeyField();
assertThat(keyField, equalTo(new Field("field2", 1, Schema.STRING_SCHEMA)));
assertThat(schemaKStream.getSchema().fields(), equalTo(schema.fields()));
}
use of io.confluent.ksql.structured.SchemaKStream in project ksql by confluentinc.
the class KsqlStructuredDataOutputNodeTest method shouldCreateSinkWithCorrectCleanupPolicyNonWindowedTable.
@Test
public void shouldCreateSinkWithCorrectCleanupPolicyNonWindowedTable() {
KafkaTopicClient topicClientForNonWindowTable = EasyMock.mock(KafkaTopicClient.class);
KsqlStructuredDataOutputNode outputNode = getKsqlStructuredDataOutputNode(false);
StreamsBuilder streamsBuilder = new StreamsBuilder();
Map<String, String> topicConfig = ImmutableMap.of(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_COMPACT);
topicClientForNonWindowTable.createTopic("output", 4, (short) 3, topicConfig);
EasyMock.replay(topicClientForNonWindowTable);
SchemaKStream schemaKStream = outputNode.buildStream(streamsBuilder, ksqlConfig, topicClientForNonWindowTable, new FunctionRegistry(), new HashMap<>(), new MockSchemaRegistryClient());
assertThat(schemaKStream, instanceOf(SchemaKTable.class));
EasyMock.verify();
}
use of io.confluent.ksql.structured.SchemaKStream in project ksql by confluentinc.
the class KsqlStructuredDataOutputNodeTest method shouldCreateSinkWithCorrectCleanupPolicyWindowedTable.
@Test
public void shouldCreateSinkWithCorrectCleanupPolicyWindowedTable() {
KafkaTopicClient topicClientForWindowTable = EasyMock.mock(KafkaTopicClient.class);
KsqlStructuredDataOutputNode outputNode = getKsqlStructuredDataOutputNode(true);
StreamsBuilder streamsBuilder = new StreamsBuilder();
topicClientForWindowTable.createTopic("output", 4, (short) 3, Collections.emptyMap());
EasyMock.replay(topicClientForWindowTable);
SchemaKStream schemaKStream = outputNode.buildStream(streamsBuilder, ksqlConfig, topicClientForWindowTable, new FunctionRegistry(), new HashMap<>(), new MockSchemaRegistryClient());
assertThat(schemaKStream, instanceOf(SchemaKTable.class));
EasyMock.verify();
}
use of io.confluent.ksql.structured.SchemaKStream in project ksql by confluentinc.
the class StructuredDataSourceNodeTest method shouldBuildSchemaKTableWhenKTableSource.
@Test
public void shouldBuildSchemaKTableWhenKTableSource() {
StructuredDataSourceNode node = new StructuredDataSourceNode(new PlanNodeId("0"), new KsqlTable("sqlExpression", "datasource", schema, schema.field("field"), schema.field("timestamp"), new KsqlTopic("topic2", "topic2", new KsqlJsonTopicSerDe()), "statestore", false), schema);
final SchemaKStream result = build(node);
assertThat(result.getClass(), equalTo(SchemaKTable.class));
}
Aggregations