use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldCreateCommandForCreateTable.
@Test
public void shouldCreateCommandForCreateTable() {
// Given:
final CreateTable ddlStatement = new CreateTable(SOME_NAME, TableElements.of(tableElement("COL1", new Type(BIGINT), PRIMARY_KEY_CONSTRAINT), tableElement("COL2", new Type(SqlTypes.STRING))), false, true, withProperties, false);
// When:
final CreateTableCommand result = createSourceFactory.createTableCommand(ddlStatement, ksqlConfig);
// Then:
assertThat(result.getSourceName(), is(SOME_NAME));
assertThat(result.getTopicName(), is(TOPIC_NAME));
assertThat(result.getIsSource(), is(false));
}
use of io.confluent.ksql.execution.expression.tree.Type 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.execution.expression.tree.Type 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.execution.expression.tree.Type in project ksql by confluentinc.
the class CommandFactoriesTest method shouldCreateCommandForCreateSourceStream.
@Test
public void shouldCreateCommandForCreateSourceStream() {
// Given:
final CreateStream statement = new CreateStream(SOME_NAME, TableElements.of(tableElement("COL1", new Type(SqlTypes.BIGINT)), tableElement("COL2", new Type(SqlTypes.STRING))), false, true, withProperties, true);
// When:
final DdlCommand result = commandFactories.create(sqlExpression, statement, SessionConfig.of(ksqlConfig, emptyMap()));
// Then:
assertThat(result, is(createStreamCommand));
verify(createSourceFactory).createStreamCommand(statement, ksqlConfig);
}
use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class CommandFactoriesTest method shouldCreateCommandForCreateSourceTable.
@Test
public void shouldCreateCommandForCreateSourceTable() {
// 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, true);
// When:
final DdlCommand result = commandFactories.create(sqlExpression, statement, SessionConfig.of(ksqlConfig, emptyMap()));
// Then:
assertThat(result, is(createTableCommand));
verify(createSourceFactory).createTableCommand(statement, ksqlConfig);
}
Aggregations