use of io.confluent.ksql.execution.ddl.commands.AlterSourceCommand in project ksql by confluentinc.
the class DdlCommandExecTest method shouldThrowOnMismatchedDatasourceType.
@Test
public void shouldThrowOnMismatchedDatasourceType() {
// Given:
alterSource = new AlterSourceCommand(EXISTING_STREAM, DataSourceType.KTABLE.getKsqlType(), NEW_COLUMNS);
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> cmdExec.execute(SQL_TEXT, alterSource, false, NO_QUERY_SOURCES));
// Then:
assertThat(e.getMessage(), is("Incompatible data source type is STREAM, but statement was ALTER TABLE"));
}
use of io.confluent.ksql.execution.ddl.commands.AlterSourceCommand in project ksql by confluentinc.
the class DdlCommandExecTest method shouldAlterTable.
@Test
public void shouldAlterTable() {
// Given:
alterSource = new AlterSourceCommand(EXISTING_TABLE, DataSourceType.KTABLE.getKsqlType(), NEW_COLUMNS);
// When:
final DdlCommandResult result = cmdExec.execute(SQL_TEXT, alterSource, false, NO_QUERY_SOURCES);
// Then:
assertThat(result.isSuccess(), is(true));
assertThat(metaStore.getSource(EXISTING_TABLE).getSchema().columns().size(), is(8));
assertThat(metaStore.getSource(EXISTING_TABLE).getSqlExpression(), is("sqlexpression\nsome ksql"));
}
use of io.confluent.ksql.execution.ddl.commands.AlterSourceCommand in project ksql by confluentinc.
the class DdlCommandExecTest method shouldAlterStream.
@Test
public void shouldAlterStream() {
// Given:
alterSource = new AlterSourceCommand(EXISTING_STREAM, DataSourceType.KSTREAM.getKsqlType(), NEW_COLUMNS);
// When:
final DdlCommandResult result = cmdExec.execute(SQL_TEXT, alterSource, false, NO_QUERY_SOURCES);
// Then:
assertThat(result.isSuccess(), is(true));
assertThat(metaStore.getSource(EXISTING_STREAM).getSchema().columns().size(), is(10));
assertThat(metaStore.getSource(EXISTING_STREAM).getSqlExpression(), is("sqlexpression\nsome ksql"));
}
use of io.confluent.ksql.execution.ddl.commands.AlterSourceCommand in project ksql by confluentinc.
the class AlterSourceFactoryTest method shouldCreateCommandForAlterStream.
@Test
public void shouldCreateCommandForAlterStream() {
// Given:
final AlterSource alterSource = new AlterSource(STREAM_NAME, DataSourceType.KSTREAM, NEW_COLUMNS);
// When:
final AlterSourceCommand result = alterSourceFactory.create(alterSource);
// Then:
assertEquals(result.getKsqlType(), DataSourceType.KSTREAM.getKsqlType());
assertEquals(result.getSourceName(), STREAM_NAME);
assertEquals(result.getNewColumns().size(), 1);
}
Aggregations