use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class SchemaParserTest method shouldParseValidSchema.
@Test
public void shouldParseValidSchema() {
// Given:
final String schema = "foo INTEGER, bar MAP<VARCHAR, VARCHAR>";
// When:
final TableElements elements = parser.parse(schema);
// Then:
assertThat(elements, contains(new TableElement(FOO, new Type(SqlTypes.INTEGER)), new TableElement(BAR, new Type(SqlTypes.map(SqlTypes.STRING, SqlTypes.STRING)))));
}
use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class SchemaParserTest method shouldParseValidSchemaWithSingleHeaderKeyField.
@Test
public void shouldParseValidSchemaWithSingleHeaderKeyField() {
// Given:
final String schema = "K STRING HEADER('k1'), bar INT";
// When:
final TableElements elements = parser.parse(schema);
// Then:
assertThat(elements, contains(new TableElement(ColumnName.of("K"), new Type(SqlTypes.STRING), HEADER_KEY1_CONSTRAINT), new TableElement(BAR, new Type(SqlTypes.INTEGER))));
}
use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class TableElementTest method shouldReturnType.
@Test
public void shouldReturnType() {
// Given:
final TableElement element = new TableElement(NAME, new Type(SqlTypes.STRING));
// Then:
assertThat(element.getType(), is(new Type(SqlTypes.STRING)));
}
use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class TableElementsTest method shouldBuildLogicalSchemaWithWithHeaders.
@Test
public void shouldBuildLogicalSchemaWithWithHeaders() {
// Given:
final TableElements tableElements = TableElements.of(tableElement("v0", INT_TYPE), tableElement("h0", new Type(SqlArray.of(SqlStruct.builder().field("KEY", SqlTypes.STRING).field("VALUE", SqlTypes.BYTES).build())), HEADERS_CONSTRAINT));
// When:
final LogicalSchema schema = tableElements.toLogicalSchema();
// Then:
assertThat(schema, is(LogicalSchema.builder().valueColumn(ColumnName.of("v0"), SqlTypes.INTEGER).headerColumn(ColumnName.of("h0"), Optional.empty()).build()));
}
use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class FeatureFlagCheckerTest method shouldThrowOnCreateStreamWithHeadersIfFeatureFlagIsDisabled.
@Test
public void shouldThrowOnCreateStreamWithHeadersIfFeatureFlagIsDisabled() {
// Given
final KsqlConfig config = new KsqlConfig(ImmutableMap.of(KsqlConfig.KSQL_HEADERS_COLUMNS_ENABLED, false));
final CreateStream createStream = new CreateStream(SourceName.of("stream1"), TableElements.of(new TableElement(ColumnName.of("col1"), new Type(SqlArray.of(SqlStruct.builder().field("KEY", SqlTypes.STRING).field("VALUE", SqlTypes.BYTES).build())), new ColumnConstraints.Builder().headers().build())), false, false, CreateSourceProperties.from(ImmutableMap.of(CommonCreateConfigs.KAFKA_TOPIC_NAME_PROPERTY, new StringLiteral("topic1"))), false);
final ConfiguredStatement configuredStatement = configured(config, createStream);
// When
final Exception e = assertThrows(KsqlException.class, () -> FeatureFlagChecker.throwOnDisabledFeatures(configuredStatement));
// Then
assertThat(e.getMessage(), containsString("Cannot create Stream because schema with headers columns is disabled."));
}
Aggregations