Search in sources :

Example 21 with DataSource

use of io.confluent.ksql.metastore.model.DataSource in project ksql by confluentinc.

the class ReplaceIntTest method assertForSource.

private void assertForSource(final String sourceName, final String topic, final Map<GenericKey, GenericRow> expected) {
    DataSource source = ksqlContext.getMetaStore().getSource(SourceName.of(sourceName));
    PhysicalSchema resultSchema = PhysicalSchema.from(source.getSchema(), source.getKsqlTopic().getKeyFormat().getFeatures(), source.getKsqlTopic().getValueFormat().getFeatures());
    assertThat(TEST_HARNESS.verifyAvailableUniqueRows(topic, expected.size(), FormatFactory.KAFKA, FormatFactory.JSON, resultSchema), is(expected));
}
Also used : PhysicalSchema(io.confluent.ksql.schema.ksql.PhysicalSchema) DataSource(io.confluent.ksql.metastore.model.DataSource)

Example 22 with DataSource

use of io.confluent.ksql.metastore.model.DataSource in project ksql by confluentinc.

the class ReplaceIntTest method shouldReplaceDDL.

@Test
public void shouldReplaceDDL() {
    // When:
    ksqlContext.sql(String.format("CREATE OR REPLACE STREAM source (%s) WITH (kafka_topic='%s', value_format='JSON');", Provider.SQL + ", col3 BIGINT", inputTopic));
    // Then:
    DataSource source = ksqlContext.getMetaStore().getSource(SourceName.of("SOURCE"));
    assertThat(source.getSchema().value().size(), is(3));
    assertThat(source.getSchema().value().get(2), is(Column.of(ColumnName.of("COL3"), SqlTypes.BIGINT, Namespace.VALUE, 2)));
}
Also used : DataSource(io.confluent.ksql.metastore.model.DataSource) IntegrationTest(io.confluent.common.utils.IntegrationTest) Test(org.junit.Test)

Example 23 with DataSource

use of io.confluent.ksql.metastore.model.DataSource in project ksql by confluentinc.

the class WindowingIntTest method assertTableCanBeUsedAsSource.

private <K> void assertTableCanBeUsedAsSource(final Map<K, GenericRow> expected, final Matcher<? super Map<K, GenericRow>> tableRowMatcher) {
    ksqlContext.sql("CREATE TABLE " + resultStream1 + " AS SELECT * FROM " + resultStream0 + ";");
    final DataSource source = ksqlContext.getMetaStore().getSource(SourceName.of(resultStream1));
    resultSchema = PhysicalSchema.from(source.getSchema(), source.getKsqlTopic().getKeyFormat().getFeatures(), source.getKsqlTopic().getValueFormat().getFeatures());
    assertOutputOf(resultStream1, expected, tableRowMatcher);
}
Also used : DataSource(io.confluent.ksql.metastore.model.DataSource)

Example 24 with DataSource

use of io.confluent.ksql.metastore.model.DataSource in project ksql by confluentinc.

the class ReplaceWithSharedRuntimesIntTest method assertForSource.

private void assertForSource(final String sourceName, final String topic, final Map<GenericKey, GenericRow> expected) {
    DataSource source = ksqlContext.getMetaStore().getSource(SourceName.of(sourceName));
    PhysicalSchema resultSchema = PhysicalSchema.from(source.getSchema(), source.getKsqlTopic().getKeyFormat().getFeatures(), source.getKsqlTopic().getValueFormat().getFeatures());
    assertThat(TEST_HARNESS.verifyAvailableUniqueRows(topic, expected.size(), FormatFactory.KAFKA, FormatFactory.JSON, resultSchema), is(expected));
}
Also used : PhysicalSchema(io.confluent.ksql.schema.ksql.PhysicalSchema) DataSource(io.confluent.ksql.metastore.model.DataSource)

Example 25 with DataSource

use of io.confluent.ksql.metastore.model.DataSource in project ksql by confluentinc.

the class ReplaceWithSharedRuntimesIntTest method shouldReplaceDDL.

@Test
public void shouldReplaceDDL() {
    // When:
    ksqlContext.sql(String.format("CREATE OR REPLACE STREAM source (%s) WITH (kafka_topic='%s', value_format='JSON');", Provider.SQL + ", col3 BIGINT", inputTopic));
    // Then:
    DataSource source = ksqlContext.getMetaStore().getSource(SourceName.of("SOURCE"));
    assertThat(source.getSchema().value().size(), is(3));
    assertThat(source.getSchema().value().get(2), is(Column.of(ColumnName.of("COL3"), SqlTypes.BIGINT, Namespace.VALUE, 2)));
}
Also used : DataSource(io.confluent.ksql.metastore.model.DataSource) IntegrationTest(io.confluent.common.utils.IntegrationTest) Test(org.junit.Test)

Aggregations

DataSource (io.confluent.ksql.metastore.model.DataSource)70 Test (org.junit.Test)25 KsqlException (io.confluent.ksql.util.KsqlException)24 SourceName (io.confluent.ksql.name.SourceName)21 KsqlTopic (io.confluent.ksql.execution.ddl.commands.KsqlTopic)12 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)12 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)10 MetricCollectors (io.confluent.ksql.metrics.MetricCollectors)9 Collectors (java.util.stream.Collectors)9 PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)8 PreparedStatement (io.confluent.ksql.parser.KsqlParser.PreparedStatement)7 KsqlStatementException (io.confluent.ksql.util.KsqlStatementException)7 Optional (java.util.Optional)7 ImmutableList (com.google.common.collect.ImmutableList)6 GenericKey (io.confluent.ksql.GenericKey)6 QueryId (io.confluent.ksql.query.QueryId)6 ServiceContext (io.confluent.ksql.services.ServiceContext)6 KsqlConfig (io.confluent.ksql.util.KsqlConfig)6 Collections (java.util.Collections)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6