Search in sources :

Example 6 with RegisterType

use of io.confluent.ksql.parser.tree.RegisterType in project ksql by confluentinc.

the class RegisterTypeFactoryTest method shouldNotThrowOnRegisterExistingTypeWhenIfNotExistsSet.

@Test
public void shouldNotThrowOnRegisterExistingTypeWhenIfNotExistsSet() {
    // Given:
    final RegisterType ddlStatement = new RegisterType(Optional.empty(), EXISTING_TYPE, new Type(SqlStruct.builder().field("foo", SqlPrimitiveType.of(SqlBaseType.STRING)).build()), true);
    // When:
    final RegisterTypeCommand result = factory.create(ddlStatement);
    // Then:
    assertThat(result.getType(), equalTo(ddlStatement.getType().getSqlType()));
    assertThat(result.getTypeName(), equalTo(EXISTING_TYPE));
}
Also used : Type(io.confluent.ksql.execution.expression.tree.Type) SqlPrimitiveType(io.confluent.ksql.schema.ksql.types.SqlPrimitiveType) SqlBaseType(io.confluent.ksql.schema.ksql.types.SqlBaseType) SqlType(io.confluent.ksql.schema.ksql.types.SqlType) RegisterType(io.confluent.ksql.parser.tree.RegisterType) RegisterType(io.confluent.ksql.parser.tree.RegisterType) RegisterTypeCommand(io.confluent.ksql.execution.ddl.commands.RegisterTypeCommand) Test(org.junit.Test)

Example 7 with RegisterType

use of io.confluent.ksql.parser.tree.RegisterType in project ksql by confluentinc.

the class TestCaseBuilderUtil method registerType.

private static void registerType(final PreparedStatement<?> prepare, final MetaStore metaStore) {
    if (prepare.getStatement() instanceof RegisterType) {
        final RegisterType statement = (RegisterType) prepare.getStatement();
        metaStore.registerType(statement.getName(), statement.getType().getSqlType());
    }
}
Also used : RegisterType(io.confluent.ksql.parser.tree.RegisterType)

Aggregations

RegisterType (io.confluent.ksql.parser.tree.RegisterType)7 Test (org.junit.Test)6 Type (io.confluent.ksql.execution.expression.tree.Type)5 SqlBaseType (io.confluent.ksql.schema.ksql.types.SqlBaseType)5 SqlPrimitiveType (io.confluent.ksql.schema.ksql.types.SqlPrimitiveType)5 SqlType (io.confluent.ksql.schema.ksql.types.SqlType)4 RegisterTypeCommand (io.confluent.ksql.execution.ddl.commands.RegisterTypeCommand)3 DdlCommand (io.confluent.ksql.execution.ddl.commands.DdlCommand)1 DataSourceType (io.confluent.ksql.metastore.model.DataSource.DataSourceType)1 DropType (io.confluent.ksql.parser.DropType)1 SqlStruct (io.confluent.ksql.schema.ksql.types.SqlStruct)1 KsqlException (io.confluent.ksql.util.KsqlException)1