use of io.confluent.ksql.parser.tree.RegisterType in project ksql by confluentinc.
the class RegisterTypeFactoryTest method shouldCreateCommandForRegisterTypeWhenIfNotExitsSet.
@Test
public void shouldCreateCommandForRegisterTypeWhenIfNotExitsSet() {
// Given:
final RegisterType ddlStatement = new RegisterType(Optional.empty(), NOT_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(NOT_EXISTING_TYPE));
}
use of io.confluent.ksql.parser.tree.RegisterType in project ksql by confluentinc.
the class RegisterTypeFactoryTest method shouldCreateCommandForRegisterTypeWhenIfNotExitsNotSet.
@Test
public void shouldCreateCommandForRegisterTypeWhenIfNotExitsNotSet() {
// Given:
final RegisterType ddlStatement = new RegisterType(Optional.empty(), NOT_EXISTING_TYPE, new Type(SqlStruct.builder().field("foo", SqlPrimitiveType.of(SqlBaseType.STRING)).build()), false);
// When:
final RegisterTypeCommand result = factory.create(ddlStatement);
// Then:
assertThat(result.getType(), equalTo(ddlStatement.getType().getSqlType()));
assertThat(result.getTypeName(), equalTo(NOT_EXISTING_TYPE));
}
use of io.confluent.ksql.parser.tree.RegisterType in project ksql by confluentinc.
the class RegisterTypeFactoryTest method shouldThrowOnRegisterExistingTypeWhenIfNotExistsNotSet.
@Test
public void shouldThrowOnRegisterExistingTypeWhenIfNotExistsNotSet() {
// Given:
final RegisterType ddlStatement = new RegisterType(Optional.empty(), EXISTING_TYPE, new Type(SqlStruct.builder().field("foo", SqlPrimitiveType.of(SqlBaseType.STRING)).build()), false);
// When:
final Exception e = assertThrows(KsqlException.class, () -> factory.create(ddlStatement));
// Then:
assertThat(e.getMessage(), equalTo("Cannot register custom type '" + EXISTING_TYPE + "' since it is already registered with type: " + customType));
}
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));
}
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());
}
}
Aggregations