Search in sources :

Example 1 with Builder

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()));
}
Also used : Builder(io.confluent.ksql.parser.tree.ColumnConstraints.Builder) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) Test(org.junit.Test)

Example 2 with Builder

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()));
}
Also used : Builder(io.confluent.ksql.parser.tree.ColumnConstraints.Builder) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) Test(org.junit.Test)

Aggregations

Builder (io.confluent.ksql.parser.tree.ColumnConstraints.Builder)2 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)2 Test (org.junit.Test)2