use of io.confluent.ksql.execution.ddl.commands.DdlCommand in project ksql by confluentinc.
the class CommandFactoriesTest method shouldCreateCommandForCreateSourceStream.
@Test
public void shouldCreateCommandForCreateSourceStream() {
// Given:
final CreateStream statement = new CreateStream(SOME_NAME, TableElements.of(tableElement("COL1", new Type(SqlTypes.BIGINT)), tableElement("COL2", new Type(SqlTypes.STRING))), false, true, withProperties, true);
// When:
final DdlCommand result = commandFactories.create(sqlExpression, statement, SessionConfig.of(ksqlConfig, emptyMap()));
// Then:
assertThat(result, is(createStreamCommand));
verify(createSourceFactory).createStreamCommand(statement, ksqlConfig);
}
use of io.confluent.ksql.execution.ddl.commands.DdlCommand in project ksql by confluentinc.
the class CommandFactoriesTest method shouldCreateCommandForCreateSourceTable.
@Test
public void shouldCreateCommandForCreateSourceTable() {
// Given:
final CreateTable statement = new CreateTable(SOME_NAME, TableElements.of(tableElement("COL1", new Type(SqlTypes.BIGINT)), tableElement("COL2", new Type(SqlTypes.STRING))), false, true, withProperties, true);
// When:
final DdlCommand result = commandFactories.create(sqlExpression, statement, SessionConfig.of(ksqlConfig, emptyMap()));
// Then:
assertThat(result, is(createTableCommand));
verify(createSourceFactory).createTableCommand(statement, ksqlConfig);
}
use of io.confluent.ksql.execution.ddl.commands.DdlCommand in project ksql by confluentinc.
the class CommandFactoriesTest method shouldCreateCommandForRegisterType.
@Test
public void shouldCreateCommandForRegisterType() {
// Given:
final RegisterType ddlStatement = new RegisterType(Optional.empty(), "alias", new Type(SqlStruct.builder().field("foo", SqlPrimitiveType.of(SqlBaseType.STRING)).build()), true);
// When:
final DdlCommand result = commandFactories.create(sqlExpression, ddlStatement, SessionConfig.of(ksqlConfig, emptyMap()));
// Then:
assertThat(result, is(registerTypeCommand));
verify(registerTypeFactory).create(ddlStatement);
}
use of io.confluent.ksql.execution.ddl.commands.DdlCommand in project ksql by confluentinc.
the class CommandFactoriesTest method shouldCreateStreamCommandWithSingleValueWrappingFromOverridesNotConfig.
@Test
public void shouldCreateStreamCommandWithSingleValueWrappingFromOverridesNotConfig() {
// Given:
givenCommandFactories();
ksqlConfig = new KsqlConfig(ImmutableMap.of(KsqlConfig.KSQL_WRAP_SINGLE_VALUES, true));
final ImmutableMap<String, Object> overrides = ImmutableMap.of(KsqlConfig.KSQL_WRAP_SINGLE_VALUES, false);
final DdlStatement statement = new CreateStream(SOME_NAME, SOME_ELEMENTS, false, true, withProperties, false);
// When:
final DdlCommand cmd = commandFactories.create(sqlExpression, statement, SessionConfig.of(ksqlConfig, overrides));
// Then:
assertThat(cmd, is(instanceOf(CreateStreamCommand.class)));
assertThat(((CreateStreamCommand) cmd).getFormats().getValueFeatures().all(), contains(SerdeFeature.UNWRAP_SINGLES));
}
Aggregations