use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatSearchedCaseExpression.
@Test
public void shouldFormatSearchedCaseExpression() {
final SearchedCaseExpression expression = new SearchedCaseExpression(Collections.singletonList(new WhenClause(new StringLiteral("foo"), new LongLiteral(1))), Optional.empty());
assertThat(ExpressionFormatter.formatExpression(expression), equalTo("(CASE WHEN 'foo' THEN 1 END)"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatSimpleCaseExpressionWithDefaultValue.
@Test
public void shouldFormatSimpleCaseExpressionWithDefaultValue() {
final SimpleCaseExpression expression = new SimpleCaseExpression(new StringLiteral("operand"), Collections.singletonList(new WhenClause(new StringLiteral("foo"), new LongLiteral(1))), Optional.of(new LongLiteral(2)));
assertThat(ExpressionFormatter.formatExpression(expression), equalTo("(CASE 'operand' WHEN 'foo' THEN 1 ELSE 2 END)"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatInPredicate.
@Test
public void shouldFormatInPredicate() {
final InPredicate predicate = new InPredicate(new StringLiteral("foo"), new InListExpression(ImmutableList.of(new StringLiteral("a"))));
assertThat(ExpressionFormatter.formatExpression(predicate), equalTo("('foo' IN ('a'))"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatSearchedCaseExpressionWithDefaultValue.
@Test
public void shouldFormatSearchedCaseExpressionWithDefaultValue() {
final SearchedCaseExpression expression = new SearchedCaseExpression(Collections.singletonList(new WhenClause(new StringLiteral("foo"), new LongLiteral(1))), Optional.of(new LongLiteral(2)));
assertThat(ExpressionFormatter.formatExpression(expression), equalTo("(CASE WHEN 'foo' THEN 1 ELSE 2 END)"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatCastToStruct.
@Test
public void shouldFormatCastToStruct() {
// Given:
final Cast cast = new Cast(new StringLiteral("foo"), new Type(SqlStruct.builder().field("field", SqlTypes.STRING).build()));
// When:
final String result = ExpressionFormatter.formatExpression(cast, FormatOptions.none());
// Then:
assertThat(result, equalTo("CAST('foo' AS STRUCT<`field` STRING>)"));
}
Aggregations