Search in sources :

Example 6 with DdlCommand

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

the class CommandFactoriesTest method shouldCreateTableCommandWithSingleValueWrappingFromOverridesNotConfig.

@Test
public void shouldCreateTableCommandWithSingleValueWrappingFromOverridesNotConfig() {
    // 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 CreateTable(SOME_NAME, ELEMENTS_WITH_PK, false, true, withProperties, false);
    // When:
    final DdlCommand cmd = commandFactories.create(sqlExpression, statement, SessionConfig.of(ksqlConfig, overrides));
    // Then:
    assertThat(cmd, is(instanceOf(CreateTableCommand.class)));
    assertThat(((CreateTableCommand) cmd).getFormats().getValueFeatures().all(), contains(SerdeFeature.UNWRAP_SINGLES));
}
Also used : DdlCommand(io.confluent.ksql.execution.ddl.commands.DdlCommand) CreateTable(io.confluent.ksql.parser.tree.CreateTable) KsqlConfig(io.confluent.ksql.util.KsqlConfig) ExecutableDdlStatement(io.confluent.ksql.parser.tree.ExecutableDdlStatement) DdlStatement(io.confluent.ksql.parser.tree.DdlStatement) Test(org.junit.Test)

Example 7 with DdlCommand

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

the class CommandFactoriesTest method shouldCreateCommandForCreateTable.

@Test
public void shouldCreateCommandForCreateTable() {
    // 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, false);
    // When:
    final DdlCommand result = commandFactories.create(sqlExpression, statement, SessionConfig.of(ksqlConfig, emptyMap()));
    // Then:
    assertThat(result, is(createTableCommand));
    verify(createSourceFactory).createTableCommand(statement, ksqlConfig);
}
Also used : RegisterType(io.confluent.ksql.parser.tree.RegisterType) SqlPrimitiveType(io.confluent.ksql.schema.ksql.types.SqlPrimitiveType) DataSourceType(io.confluent.ksql.metastore.model.DataSource.DataSourceType) SqlBaseType(io.confluent.ksql.schema.ksql.types.SqlBaseType) Type(io.confluent.ksql.execution.expression.tree.Type) DropType(io.confluent.ksql.parser.DropType) DdlCommand(io.confluent.ksql.execution.ddl.commands.DdlCommand) CreateTable(io.confluent.ksql.parser.tree.CreateTable) Test(org.junit.Test)

Example 8 with DdlCommand

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

the class CommandFactoriesTest method shouldCreateCommandForDropTable.

@Test
public void shouldCreateCommandForDropTable() {
    // Given:
    final DropTable ddlStatement = new DropTable(TABLE_NAME, true, true);
    // When:
    final DdlCommand result = commandFactories.create(sqlExpression, ddlStatement, SessionConfig.of(ksqlConfig, emptyMap()));
    // Then:
    assertThat(result, is(dropSourceCommand));
    verify(dropSourceFactory).create(ddlStatement);
}
Also used : DdlCommand(io.confluent.ksql.execution.ddl.commands.DdlCommand) DropTable(io.confluent.ksql.parser.tree.DropTable) Test(org.junit.Test)

Example 9 with DdlCommand

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

the class CommandFactoriesTest method shouldCreateCommandForCreateStream.

@Test
public void shouldCreateCommandForCreateStream() {
    // Given:
    final CreateStream statement = new CreateStream(SOME_NAME, SOME_ELEMENTS, false, true, withProperties, false);
    // When:
    final DdlCommand result = commandFactories.create(sqlExpression, statement, SessionConfig.of(ksqlConfig, emptyMap()));
    assertThat(result, is(createStreamCommand));
    verify(createSourceFactory).createStreamCommand(statement, ksqlConfig);
}
Also used : DdlCommand(io.confluent.ksql.execution.ddl.commands.DdlCommand) CreateStream(io.confluent.ksql.parser.tree.CreateStream) Test(org.junit.Test)

Example 10 with DdlCommand

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

the class DropSourceFactoryTest method shouldCreateCommandForDropTable.

@Test
public void shouldCreateCommandForDropTable() {
    // Given:
    final DropTable ddlStatement = new DropTable(TABLE_NAME, true, true);
    // When:
    final DdlCommand result = dropSourceFactory.create(ddlStatement);
    // Then:
    assertThat(result, instanceOf(DropSourceCommand.class));
}
Also used : DdlCommand(io.confluent.ksql.execution.ddl.commands.DdlCommand) DropSourceCommand(io.confluent.ksql.execution.ddl.commands.DropSourceCommand) DropTable(io.confluent.ksql.parser.tree.DropTable) Test(org.junit.Test)

Aggregations

DdlCommand (io.confluent.ksql.execution.ddl.commands.DdlCommand)14 Test (org.junit.Test)12 DataSourceType (io.confluent.ksql.metastore.model.DataSource.DataSourceType)5 CreateStream (io.confluent.ksql.parser.tree.CreateStream)5 CreateTable (io.confluent.ksql.parser.tree.CreateTable)5 Type (io.confluent.ksql.execution.expression.tree.Type)4 DropType (io.confluent.ksql.parser.DropType)4 ExecutableDdlStatement (io.confluent.ksql.parser.tree.ExecutableDdlStatement)4 RegisterType (io.confluent.ksql.parser.tree.RegisterType)3 SqlBaseType (io.confluent.ksql.schema.ksql.types.SqlBaseType)3 SqlPrimitiveType (io.confluent.ksql.schema.ksql.types.SqlPrimitiveType)3 KsqlConfig (io.confluent.ksql.util.KsqlConfig)3 DropSourceCommand (io.confluent.ksql.execution.ddl.commands.DropSourceCommand)2 DropStream (io.confluent.ksql.parser.tree.DropStream)2 QueryContainer (io.confluent.ksql.parser.tree.QueryContainer)2 KsqlStructuredDataOutputNode (io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode)2 KsqlException (io.confluent.ksql.util.KsqlException)2 KsqlStatementException (io.confluent.ksql.util.KsqlStatementException)2 Throwables (com.google.common.base.Throwables)1 ImmutableMap (com.google.common.collect.ImmutableMap)1