use of io.confluent.ksql.execution.ddl.commands.KsqlTopic 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.execution.ddl.commands.KsqlTopic in project ksql by confluentinc.
the class ExplainExecutorTest method givenPersistentQuery.
@SuppressWarnings("SameParameterValue")
public static PersistentQueryMetadata givenPersistentQuery(final String id) {
final PersistentQueryMetadata metadata = mock(PersistentQueryMetadata.class);
when(metadata.getQueryApplicationId()).thenReturn("consumer-group-id");
when(metadata.getQueryId()).thenReturn(new QueryId(id));
when(metadata.getSinkName()).thenReturn(Optional.of(SourceName.of(id)));
when(metadata.getLogicalSchema()).thenReturn(TemporaryEngine.SCHEMA);
when(metadata.getState()).thenReturn(KafkaStreams.State.valueOf(STATE.toString()));
when(metadata.getTopologyDescription()).thenReturn("topology");
when(metadata.getExecutionPlan()).thenReturn("plan");
when(metadata.getStatementString()).thenReturn("sql");
when(metadata.getQueryType()).thenReturn(KsqlConstants.KsqlQueryType.PERSISTENT);
final KsqlTopic sinkTopic = mock(KsqlTopic.class);
when(sinkTopic.getKeyFormat()).thenReturn(KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()));
when(metadata.getResultTopic()).thenReturn(Optional.of(sinkTopic));
return metadata;
}
use of io.confluent.ksql.execution.ddl.commands.KsqlTopic in project ksql by confluentinc.
the class ListQueriesExecutorTest method givenPersistentQuery.
public static PersistentQueryMetadata givenPersistentQuery(final String id, final KafkaStreams.State state, final Set<StreamsTaskMetadata> tasksMetadata) {
final PersistentQueryMetadata metadata = mock(PersistentQueryMetadata.class);
mockQuery(id, state, metadata);
when(metadata.getQueryType()).thenReturn(KsqlConstants.KsqlQueryType.PERSISTENT);
when(metadata.getSinkName()).thenReturn(Optional.of(SourceName.of(id)));
final KsqlTopic sinkTopic = mock(KsqlTopic.class);
when(sinkTopic.getKeyFormat()).thenReturn(KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()));
when(sinkTopic.getKafkaTopicName()).thenReturn(id);
when(metadata.getResultTopic()).thenReturn(Optional.of(sinkTopic));
when(metadata.getTaskMetadata()).thenReturn(tasksMetadata);
return metadata;
}
use of io.confluent.ksql.execution.ddl.commands.KsqlTopic in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldCreateStreamCommandFromNodeOutput.
@Test
public void shouldCreateStreamCommandFromNodeOutput() {
// Given:
final KsqlTopic ksqlTopic = mock(KsqlTopic.class);
when(ksqlTopic.getKafkaTopicName()).thenReturn(TOPIC_NAME);
when(ksqlTopic.getKeyFormat()).thenReturn(SOME_KEY_FORMAT);
when(ksqlTopic.getValueFormat()).thenReturn(SOME_VALUE_FORMAT);
final KsqlStructuredDataOutputNode outputNode = mock(KsqlStructuredDataOutputNode.class);
when(outputNode.getSinkName()).thenReturn(Optional.of(SOME_NAME));
when(outputNode.getSchema()).thenReturn(EXPECTED_SCHEMA);
when(outputNode.getTimestampColumn()).thenReturn(Optional.of(TIMESTAMP_COLUMN));
when(outputNode.getKsqlTopic()).thenReturn(ksqlTopic);
// When:
final CreateStreamCommand result = createSourceFactory.createStreamCommand(outputNode);
// Then:
assertThat(result.getSourceName(), is(SOME_NAME));
assertThat(result.getSchema(), is(EXPECTED_SCHEMA));
assertThat(result.getTimestampColumn(), is(Optional.of(TIMESTAMP_COLUMN)));
assertThat(result.getTopicName(), is(TOPIC_NAME));
assertThat(result.getFormats(), is(Formats.from(ksqlTopic)));
assertThat(result.getWindowInfo(), is(Optional.empty()));
assertThat(result.isOrReplace(), is(false));
}
use of io.confluent.ksql.execution.ddl.commands.KsqlTopic in project ksql by confluentinc.
the class TopicCreateInjectorTest method setUp.
@Before
public void setUp() {
parser = new DefaultKsqlParser();
metaStore = new MetaStoreImpl(new InternalFunctionRegistry());
overrides = new HashMap<>();
config = new KsqlConfig(new HashMap<>());
injector = new TopicCreateInjector(topicClient, metaStore);
final KsqlTopic sourceTopic = new KsqlTopic("source", KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()), ValueFormat.of(FormatInfo.of(FormatFactory.JSON.name()), SerdeFeatures.of()));
final KsqlStream<?> source = new KsqlStream<>("", SourceName.of("SOURCE"), SCHEMA, Optional.empty(), false, sourceTopic, false);
metaStore.putSource(source, false);
final KsqlTopic joinTopic = new KsqlTopic("jSource", KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()), ValueFormat.of(FormatInfo.of(FormatFactory.JSON.name()), SerdeFeatures.of()));
final KsqlStream<?> joinSource = new KsqlStream<>("", SourceName.of("J_SOURCE"), SCHEMA, Optional.empty(), false, joinTopic, false);
metaStore.putSource(joinSource, false);
when(topicClient.describeTopic("source")).thenReturn(sourceDescription);
when(topicClient.isTopicExists("source")).thenReturn(true);
when(builder.withName(any())).thenReturn(builder);
when(builder.withWithClause(any(), any(), any())).thenReturn(builder);
when(builder.withSource(any())).thenReturn(builder);
when(builder.build()).thenReturn(new TopicProperties("name", 1, (short) 1));
}
Aggregations