use of io.confluent.ksql.execution.ddl.commands.CreateStreamCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldCreateStreamCommandWithSingleValueWrappingFromPropertiesNotConfig.
@Test
public void shouldCreateStreamCommandWithSingleValueWrappingFromPropertiesNotConfig() {
// Given:
ksqlConfig = new KsqlConfig(ImmutableMap.of(KsqlConfig.KSQL_WRAP_SINGLE_VALUES, true));
final ImmutableMap<String, Object> overrides = ImmutableMap.of(KsqlConfig.KSQL_WRAP_SINGLE_VALUES, true);
givenProperty(CommonCreateConfigs.WRAP_SINGLE_VALUE, new BooleanLiteral("false"));
final CreateStream statement = new CreateStream(SOME_NAME, ONE_KEY_ONE_VALUE, false, true, withProperties, false);
// When:
final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig.cloneWithPropertyOverwrite(overrides));
// Then:
assertThat(cmd.getFormats().getValueFeatures(), is(SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES)));
}
use of io.confluent.ksql.execution.ddl.commands.CreateStreamCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldBuildTimestampColumnWithFormat.
@Test
public void shouldBuildTimestampColumnWithFormat() {
// Given:
givenProperties(ImmutableMap.of(CommonCreateConfigs.TIMESTAMP_NAME_PROPERTY, new StringLiteral(quote(ELEMENT1.getName().text())), CommonCreateConfigs.TIMESTAMP_FORMAT_PROPERTY, new StringLiteral("%s")));
final CreateStream statement = new CreateStream(SOME_NAME, STREAM_ELEMENTS, false, true, withProperties, false);
// When:
final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getTimestampColumn(), is(Optional.of(new TimestampColumn(ELEMENT1.getName(), Optional.of("%s")))));
}
use of io.confluent.ksql.execution.ddl.commands.CreateStreamCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldDefaultToKafkaKeySerdeForStream.
@Test
public void shouldDefaultToKafkaKeySerdeForStream() {
final CreateStream statement = new CreateStream(SOME_NAME, ONE_KEY_ONE_VALUE, false, true, withProperties, false);
// When:
final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getFormats().getKeyFormat(), is(FormatInfo.of(KAFKA.name())));
assertThat(cmd.getWindowInfo(), is(Optional.empty()));
}
use of io.confluent.ksql.execution.ddl.commands.CreateStreamCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldNotThrowOnCreateStreamIfNotExistsIsSet.
@Test
public void shouldNotThrowOnCreateStreamIfNotExistsIsSet() {
// Given:
final CreateStream ddlStatement = new CreateStream(SOME_NAME, STREAM_ELEMENTS, false, true, withProperties, false);
// When:
final CreateStreamCommand result = createSourceFactory.createStreamCommand(ddlStatement, ksqlConfig);
// Then:
assertThat(result.getSourceName(), is(SOME_NAME));
}
use of io.confluent.ksql.execution.ddl.commands.CreateStreamCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldHandleSessionWindowedKeyForStream.
@Test
public void shouldHandleSessionWindowedKeyForStream() {
// Given:
givenProperty("window_type", new StringLiteral("session"));
final CreateStream statement = new CreateStream(SOME_NAME, STREAM_ELEMENTS, false, true, withProperties, false);
// When:
final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getFormats().getKeyFormat(), is(FormatInfo.of(KAFKA.name())));
assertThat(cmd.getWindowInfo(), is(Optional.of(WindowInfo.of(SESSION, Optional.empty()))));
}
Aggregations