Search in sources :

Example 1 with FormatOptions

use of io.confluent.ksql.schema.utils.FormatOptions in project ksql by confluentinc.

the class LogicalSchemaTest method shouldConvertSchemaToStringWithReservedWords.

@Test
public void shouldConvertSchemaToStringWithReservedWords() {
    // Given:
    final LogicalSchema schema = LogicalSchema.builder().keyColumn(K0, DOUBLE).valueColumn(F0, BOOLEAN).valueColumn(F1, SqlTypes.struct().field("f0", BIGINT).field("f1", BIGINT).build()).build();
    final FormatOptions formatOptions = FormatOptions.of(word -> word.equalsIgnoreCase("f0"));
    // When:
    final String s = schema.toString(formatOptions);
    // Then:
    assertThat(s, is("k0 DOUBLE KEY, " + "`f0` BOOLEAN, " + "f1 STRUCT<`f0` BIGINT, f1 BIGINT>"));
}
Also used : FormatOptions(io.confluent.ksql.schema.utils.FormatOptions) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 2 with FormatOptions

use of io.confluent.ksql.schema.utils.FormatOptions in project ksql by confluentinc.

the class ColumnTest method shouldToStringWithReservedWords.

@Test
public void shouldToStringWithReservedWords() {
    // Given:
    final FormatOptions options = FormatOptions.of(identifier -> identifier.equals("reserved") || identifier.equals("word"));
    // Then:
    assertThat(Column.of(ColumnName.of("not-reserved"), BIGINT, VALUE, 0).toString(options), is("not-reserved BIGINT"));
    assertThat(Column.of(ColumnName.of("reserved"), BIGINT, VALUE, 0).toString(options), is("`reserved` BIGINT"));
    assertThat(Column.of(ColumnName.of("word"), DOUBLE, VALUE, 0).toString(options), is("`word` DOUBLE"));
    assertThat(Column.of(ColumnName.of("word"), STRING, VALUE, 0).toString(options), is("`word` STRING"));
}
Also used : FormatOptions(io.confluent.ksql.schema.utils.FormatOptions) Test(org.junit.Test)

Aggregations

FormatOptions (io.confluent.ksql.schema.utils.FormatOptions)2 Test (org.junit.Test)2 Matchers.containsString (org.hamcrest.Matchers.containsString)1