use of io.confluent.ksql.execution.ddl.commands.CreateTableCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldBuildTimestampColumnForTable.
@Test
public void shouldBuildTimestampColumnForTable() {
// Given:
givenProperty(CommonCreateConfigs.TIMESTAMP_NAME_PROPERTY, new StringLiteral(quote(ELEMENT2.getName().text())));
final CreateTable statement = new CreateTable(SOME_NAME, TABLE_ELEMENTS, false, true, withProperties, false);
// When:
final CreateTableCommand cmd = createSourceFactory.createTableCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getTimestampColumn(), is(Optional.of(new TimestampColumn(ELEMENT2.getName(), Optional.empty()))));
}
use of io.confluent.ksql.execution.ddl.commands.CreateTableCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldCreateCommandForCreateSourceTable.
@Test
public void shouldCreateCommandForCreateSourceTable() {
// Given:
final CreateTable ddlStatement = new CreateTable(SOME_NAME, TableElements.of(tableElement("COL1", new Type(BIGINT), PRIMARY_KEY_CONSTRAINT), tableElement("COL2", new Type(SqlTypes.STRING))), false, true, withProperties, true);
// When:
final CreateTableCommand result = createSourceFactory.createTableCommand(ddlStatement, ksqlConfig);
// Then:
assertThat(result.getSourceName(), is(SOME_NAME));
assertThat(result.getTopicName(), is(TOPIC_NAME));
assertThat(result.getIsSource(), is(true));
}
use of io.confluent.ksql.execution.ddl.commands.CreateTableCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldCreateCommandForCreateTable.
@Test
public void shouldCreateCommandForCreateTable() {
// Given:
final CreateTable ddlStatement = new CreateTable(SOME_NAME, TableElements.of(tableElement("COL1", new Type(BIGINT), PRIMARY_KEY_CONSTRAINT), tableElement("COL2", new Type(SqlTypes.STRING))), false, true, withProperties, false);
// When:
final CreateTableCommand result = createSourceFactory.createTableCommand(ddlStatement, ksqlConfig);
// Then:
assertThat(result.getSourceName(), is(SOME_NAME));
assertThat(result.getTopicName(), is(TOPIC_NAME));
assertThat(result.getIsSource(), is(false));
}
use of io.confluent.ksql.execution.ddl.commands.CreateTableCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldCreateTableCommandWithSingleValueWrappingFromPropertiesNotConfig.
@Test
public void shouldCreateTableCommandWithSingleValueWrappingFromPropertiesNotConfig() {
// 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 CreateTable statement = new CreateTable(SOME_NAME, TABLE_ELEMENTS_1_VALUE, false, true, withProperties, false);
// When:
final CreateTableCommand cmd = createSourceFactory.createTableCommand(statement, ksqlConfig.cloneWithPropertyOverwrite(overrides));
// Then:
assertThat(cmd.getFormats().getValueFeatures(), is(SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES)));
}
use of io.confluent.ksql.execution.ddl.commands.CreateTableCommand in project ksql by confluentinc.
the class KsqlPlanV1Test method shouldReturnCreateAsPersistentQueryTypeOnCreateTable.
@Test
public void shouldReturnCreateAsPersistentQueryTypeOnCreateTable() {
// Given:
final CreateTableCommand ddlCommand = Mockito.mock(CreateTableCommand.class);
when(ddlCommand.getIsSource()).thenReturn(false);
final KsqlPlanV1 plan = new KsqlPlanV1("stmt", Optional.of(ddlCommand), Optional.of(queryPlan1));
// When/Then:
assertThat(plan.getPersistentQueryType(), is(Optional.of(KsqlConstants.PersistentQueryType.CREATE_AS)));
}
Aggregations