Search in sources :

Example 6 with DdlCommandResult

use of io.confluent.ksql.execution.ddl.commands.DdlCommandResult in project ksql by confluentinc.

the class DdlCommandExecTest method shouldDropMissingSource.

@Test
public void shouldDropMissingSource() {
    // Given:
    givenDropSourceCommand(STREAM_NAME);
    // When:
    final DdlCommandResult result = cmdExec.execute(SQL_TEXT, dropSource, false, NO_QUERY_SOURCES);
    // Then:
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getMessage(), equalTo("Source " + STREAM_NAME + " does not exist."));
}
Also used : DdlCommandResult(io.confluent.ksql.execution.ddl.commands.DdlCommandResult) Test(org.junit.Test)

Example 7 with DdlCommandResult

use of io.confluent.ksql.execution.ddl.commands.DdlCommandResult 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"));
}
Also used : DdlCommandResult(io.confluent.ksql.execution.ddl.commands.DdlCommandResult) AlterSourceCommand(io.confluent.ksql.execution.ddl.commands.AlterSourceCommand) Test(org.junit.Test)

Example 8 with DdlCommandResult

use of io.confluent.ksql.execution.ddl.commands.DdlCommandResult in project ksql by confluentinc.

the class DdlCommandExecTest method shouldDropExistingType.

@Test
public void shouldDropExistingType() {
    // Given:
    metaStore.registerType("type", SqlTypes.STRING);
    // When:
    final DdlCommandResult result = cmdExec.execute(SQL_TEXT, dropType, false, NO_QUERY_SOURCES);
    // Then:
    assertThat(metaStore.resolveType("type").isPresent(), is(false));
    assertThat("Expected successful execution", result.isSuccess());
    assertThat(result.getMessage(), is("Dropped type 'type'"));
}
Also used : DdlCommandResult(io.confluent.ksql.execution.ddl.commands.DdlCommandResult) Test(org.junit.Test)

Example 9 with DdlCommandResult

use of io.confluent.ksql.execution.ddl.commands.DdlCommandResult in project ksql by confluentinc.

the class DdlCommandExecTest method shouldWarnAddDuplicateStreamWithoutReplace.

@Test
public void shouldWarnAddDuplicateStreamWithoutReplace() {
    // Given:
    givenCreateStream();
    cmdExec.execute(SQL_TEXT, createStream, false, NO_QUERY_SOURCES);
    // When:
    givenCreateStream(SCHEMA2, false);
    final DdlCommandResult result = cmdExec.execute(SQL_TEXT, createStream, false, NO_QUERY_SOURCES);
    // Then:
    assertThat("Expected successful execution", result.isSuccess());
    assertThat(result.getMessage(), containsString("A stream with the same name already exists"));
}
Also used : DdlCommandResult(io.confluent.ksql.execution.ddl.commands.DdlCommandResult) Test(org.junit.Test)

Example 10 with DdlCommandResult

use of io.confluent.ksql.execution.ddl.commands.DdlCommandResult 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"));
}
Also used : DdlCommandResult(io.confluent.ksql.execution.ddl.commands.DdlCommandResult) AlterSourceCommand(io.confluent.ksql.execution.ddl.commands.AlterSourceCommand) Test(org.junit.Test)

Aggregations

DdlCommandResult (io.confluent.ksql.execution.ddl.commands.DdlCommandResult)11 Test (org.junit.Test)11 AlterSourceCommand (io.confluent.ksql.execution.ddl.commands.AlterSourceCommand)2 CreateStreamCommand (io.confluent.ksql.execution.ddl.commands.CreateStreamCommand)1 DropSourceCommand (io.confluent.ksql.execution.ddl.commands.DropSourceCommand)1