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>"));
}
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"));
}
Aggregations