use of io.confluent.ksql.metastore.model.KsqlStream in project ksql by confluentinc.
the class AnalyzerFunctionalTest method shouldNotInheritNamespaceExplicitlySetUpstreamForAvro.
@Test
public void shouldNotInheritNamespaceExplicitlySetUpstreamForAvro() {
final String simpleQuery = "create stream s1 as select * from S0;";
final MutableMetaStore newAvroMetaStore = avroMetaStore.copy();
final KsqlTopic ksqlTopic = new KsqlTopic("s0", KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()), ValueFormat.of(FormatInfo.of(FormatFactory.AVRO.name(), ImmutableMap.of(ConnectProperties.FULL_SCHEMA_NAME, "org.ac.s1")), SerdeFeatures.of()));
final LogicalSchema schema = LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(ColumnName.of("FIELD1"), SqlTypes.BIGINT).build();
final KsqlStream<?> ksqlStream = new KsqlStream<>("create stream s0 with(KAFKA_TOPIC='s0', VALUE_AVRO_SCHEMA_FULL_NAME='org.ac.s1', VALUE_FORMAT='avro');", SourceName.of("S0"), schema, Optional.empty(), false, ksqlTopic, false);
newAvroMetaStore.putSource(ksqlStream, false);
final List<Statement> statements = parse(simpleQuery, newAvroMetaStore);
final CreateStreamAsSelect createStreamAsSelect = (CreateStreamAsSelect) statements.get(0);
final Query query = createStreamAsSelect.getQuery();
final Analyzer analyzer = new Analyzer(newAvroMetaStore, "", ROWPARTITION_ROWOFFSET_ENABLED, PULL_LIMIT_CLAUSE_ENABLED);
final Analysis analysis = analyzer.analyze(query, Optional.of(createStreamAsSelect.getSink()));
assertThat(analysis.getInto(), is(not(Optional.empty())));
assertThat(analysis.getInto().get().getNewTopic().get().getValueFormat(), is(FormatInfo.of(FormatFactory.AVRO.name())));
}
use of io.confluent.ksql.metastore.model.KsqlStream in project ksql by confluentinc.
the class ListSourceExecutor method describeStreams.
public static StatementExecutorResponse describeStreams(final ConfiguredStatement<DescribeStreams> statement, final SessionProperties sessionProperties, final KsqlExecutionContext executionContext, final ServiceContext serviceContext) {
final List<KsqlStream<?>> ksqlStreams = getSpecificStreams(executionContext);
final DescribeStreams describeStreams = statement.getStatement();
return StatementExecutorResponse.handled(sourceDescriptionList(statement, sessionProperties, executionContext, serviceContext, ksqlStreams, describeStreams.getShowExtended()));
}
use of io.confluent.ksql.metastore.model.KsqlStream in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldThrowInCreateStreamOrReplaceOnSourceStreams.
@Test
public void shouldThrowInCreateStreamOrReplaceOnSourceStreams() {
// Given:
final SourceName existingStreamName = SourceName.of("existingStreamName");
final KsqlStream existingStream = mock(KsqlStream.class);
when(existingStream.getDataSourceType()).thenReturn(DataSourceType.KSTREAM);
when(existingStream.isSource()).thenReturn(true);
when(metaStore.getSource(existingStreamName)).thenReturn(existingStream);
final CreateStream ddlStatement = new CreateStream(existingStreamName, STREAM_ELEMENTS, true, false, withProperties, false);
// When:
final Exception e = assertThrows(KsqlException.class, () -> createSourceFactory.createStreamCommand(ddlStatement, ksqlConfig));
// Then:
assertThat(e.getMessage(), containsString("Cannot add stream 'existingStreamName': CREATE OR REPLACE is not supported on " + "source streams."));
}
Aggregations