use of io.confluent.ksql.parser.tree.ColumnConstraints.Builder in project ksql by confluentinc.
the class TableElementsTest method shouldBuildLogicalSchemaWithWithExtractedHeader.
@Test
public void shouldBuildLogicalSchemaWithWithExtractedHeader() {
// Given:
final TableElements tableElements = TableElements.of(tableElement("v0", INT_TYPE), tableElement("h0", BYTES_TYPE, new Builder().header("key").build()));
// When:
final LogicalSchema schema = tableElements.toLogicalSchema();
// Then:
assertThat(schema, is(LogicalSchema.builder().valueColumn(ColumnName.of("v0"), SqlTypes.INTEGER).headerColumn(ColumnName.of("h0"), Optional.of("key")).build()));
}
use of io.confluent.ksql.parser.tree.ColumnConstraints.Builder in project ksql by confluentinc.
the class TableElementsTest method shouldBuildLogicalSchemaWithKeyHeaderAndValueColumnsInterleaved.
@Test
public void shouldBuildLogicalSchemaWithKeyHeaderAndValueColumnsInterleaved() {
// Given:
final TableElements tableElements = TableElements.of(tableElement("v0", INT_TYPE), tableElement("k0", INT_TYPE, KEY_CONSTRAINT), tableElement("v1", STRING_TYPE), tableElement("h1", BYTES_TYPE, new Builder().header("key").build()), tableElement("k1", INT_TYPE, KEY_CONSTRAINT));
// When:
final LogicalSchema schema = tableElements.toLogicalSchema();
// Then:
assertThat(schema, is(LogicalSchema.builder().valueColumn(ColumnName.of("v0"), SqlTypes.INTEGER).keyColumn(ColumnName.of("k0"), SqlTypes.INTEGER).valueColumn(ColumnName.of("v1"), SqlTypes.STRING).headerColumn(ColumnName.of("h1"), Optional.of("key")).keyColumn(ColumnName.of("k1"), SqlTypes.INTEGER).build()));
}
Aggregations