use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatCast.
@Test
public void shouldFormatCast() {
// Given:
final Cast cast = new Cast(new LongLiteral(1), new Type(SqlTypes.DOUBLE));
// When:
final String result = ExpressionFormatter.formatExpression(cast);
// Then:
assertThat(result, equalTo("CAST(1 AS DOUBLE)"));
}
use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatStruct.
@Test
public void shouldFormatStruct() {
final SqlStruct struct = SqlStruct.builder().field("field1", SqlTypes.INTEGER).field("field2", SqlTypes.STRING).build();
assertThat(ExpressionFormatter.formatExpression(new Type(struct)), equalTo("STRUCT<field1 INTEGER, field2 STRING>"));
}
use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class SqlFormatterTest method shouldFormatTableElementsNamedAfterReservedWords.
@Test
public void shouldFormatTableElementsNamedAfterReservedWords() {
// Given:
final TableElements tableElements = TableElements.of(new TableElement(ColumnName.of("GROUP"), new Type(SqlTypes.STRING)), new TableElement(ColumnName.of("Having"), new Type(SqlTypes.STRING)));
final CreateStream createStream = new CreateStream(TEST, tableElements, false, false, SOME_WITH_PROPS, false);
// When:
final String sql = SqlFormatter.formatSql(createStream);
// Then:
assertThat("literal escaping failure", sql, containsString("`GROUP` STRING"));
assertThat("lowercase literal escaping failure", sql, containsString("`Having` STRING"));
assertValidSql(sql);
}
use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class SchemaParserTest method shouldParseQuotedMixedCase.
@Test
public void shouldParseQuotedMixedCase() {
// Given:
final String schema = "`End` VARCHAR";
// When:
final TableElements elements = parser.parse(schema);
// Then:
assertThat(elements, hasItem(new TableElement(ColumnName.of("End"), new Type(SqlTypes.STRING))));
}
use of io.confluent.ksql.execution.expression.tree.Type in project ksql by confluentinc.
the class SchemaParserTest method shouldParseValidSchemaWithKeyField.
@Test
public void shouldParseValidSchemaWithKeyField() {
// Given:
final String schema = "K STRING KEY, bar INT";
// When:
final TableElements elements = parser.parse(schema);
// Then:
assertThat(elements, contains(new TableElement(ColumnName.of("K"), new Type(SqlTypes.STRING), KEY_CONSTRAINT), new TableElement(BAR, new Type(SqlTypes.INTEGER))));
}
Aggregations