use of io.confluent.ksql.execution.ddl.commands.CreateTableCommand in project ksql by confluentinc.
the class KsqlPlanV1Test method shouldReturnCreateSourcePersistentQueryTypeOnCreateSourceTable.
@Test
public void shouldReturnCreateSourcePersistentQueryTypeOnCreateSourceTable() {
// Given:
final CreateTableCommand ddlCommand = Mockito.mock(CreateTableCommand.class);
when(ddlCommand.getIsSource()).thenReturn(true);
final KsqlPlanV1 plan = new KsqlPlanV1("stmt", Optional.of(ddlCommand), Optional.of(queryPlan1));
// When/Then:
assertThat(plan.getPersistentQueryType(), is(Optional.of(KsqlConstants.PersistentQueryType.CREATE_SOURCE)));
}
use of io.confluent.ksql.execution.ddl.commands.CreateTableCommand in project ksql by confluentinc.
the class DdlCommandExecTest method shouldAddSourceTable.
@Test
public void shouldAddSourceTable() {
// Given:
final CreateTableCommand cmd = buildCreateTable(TABLE_NAME, false, true);
// When:
cmdExec.execute(SQL_TEXT, cmd, true, ImmutableSet.of(TABLE_NAME));
// Then:
final KsqlTable ksqlTable = (KsqlTable) metaStore.getSource(TABLE_NAME);
assertThat(ksqlTable.isSource(), is(true));
// Check query source was not added as constraints for source tables
assertThat(metaStore.getSourceConstraints(TABLE_NAME), is(NO_QUERY_SOURCES));
}
use of io.confluent.ksql.execution.ddl.commands.CreateTableCommand in project ksql by confluentinc.
the class DdlCommandExecTest method shouldAddNormalTableWhenNoTypeIsSpecified.
@Test
public void shouldAddNormalTableWhenNoTypeIsSpecified() {
// Given:
final CreateTableCommand cmd = buildCreateTable(SourceName.of("t1"), false, null);
// When:
cmdExec.execute(SQL_TEXT, cmd, true, NO_QUERY_SOURCES);
// Then:
final KsqlTable ksqlTable = (KsqlTable) metaStore.getSource(SourceName.of("t1"));
assertThat(ksqlTable.isSource(), is(false));
}
use of io.confluent.ksql.execution.ddl.commands.CreateTableCommand in project ksql by confluentinc.
the class DdlCommandExecTest method shouldThrowOnDropTableWhenConstraintExist.
@Test
public void shouldThrowOnDropTableWhenConstraintExist() {
// Given:
final CreateTableCommand table1 = buildCreateTable(SourceName.of("t1"), false, false);
final CreateTableCommand table2 = buildCreateTable(SourceName.of("t2"), false, false);
final CreateTableCommand table3 = buildCreateTable(SourceName.of("t3"), false, false);
cmdExec.execute(SQL_TEXT, table1, true, Collections.emptySet());
cmdExec.execute(SQL_TEXT, table2, true, Collections.singleton(SourceName.of("t1")));
cmdExec.execute(SQL_TEXT, table3, true, Collections.singleton(SourceName.of("t1")));
// When:
final DropSourceCommand dropStream = buildDropSourceCommand(SourceName.of("t1"));
final Exception e = assertThrows(KsqlReferentialIntegrityException.class, () -> cmdExec.execute(SQL_TEXT, dropStream, false, Collections.emptySet()));
// Then:
assertThat(e.getMessage(), containsString("Cannot drop t1."));
assertThat(e.getMessage(), containsString("The following streams and/or tables read from this source: [t2, t3]."));
assertThat(e.getMessage(), containsString("You need to drop them before dropping t1."));
}
use of io.confluent.ksql.execution.ddl.commands.CreateTableCommand in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldCreateTableCommandWithSingleValueWrappingFromConfig.
@Test
public void shouldCreateTableCommandWithSingleValueWrappingFromConfig() {
// Given:
ksqlConfig = new KsqlConfig(ImmutableMap.of(KsqlConfig.KSQL_WRAP_SINGLE_VALUES, false));
final CreateTable statement = new CreateTable(SOME_NAME, TABLE_ELEMENTS_1_VALUE, false, true, withProperties, false);
// When:
final CreateTableCommand cmd = createSourceFactory.createTableCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getFormats().getValueFeatures(), is(SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES)));
}
Aggregations