use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldAllowNonStringKeyColumn.
@Test
public void shouldAllowNonStringKeyColumn() {
// Given:
final CreateStream statement = new CreateStream(SOME_NAME, TableElements.of(tableElement("k", new Type(SqlTypes.INTEGER), KEY_CONSTRAINT)), false, true, withProperties, false);
// When:
final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getSchema().key(), contains(keyColumn(ColumnName.of("k"), SqlTypes.INTEGER)));
}
use of io.confluent.ksql.execution.expression.tree.Type 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.execution.expression.tree.Type 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.execution.expression.tree.Type in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldNotThrowOnCreateTableIfNotExistsIsSet.
@Test
public void shouldNotThrowOnCreateTableIfNotExistsIsSet() {
// Given
final CreateTable ddlStatement = new CreateTable(TABLE_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(TABLE_NAME));
}
use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldThrowOnWindowStartValueColumn.
@Test
public void shouldThrowOnWindowStartValueColumn() {
// Given:
final CreateStream statement = new CreateStream(SOME_NAME, TableElements.of(tableElement(WINDOWSTART_NAME.text(), new Type(BIGINT))), false, true, withProperties, false);
// When:
final Exception e = assertThrows(KsqlException.class, () -> createSourceFactory.createStreamCommand(statement, ksqlConfig));
// Then:
assertThat(e.getMessage(), containsString("'WINDOWSTART' is a reserved column name."));
}
Aggregations