use of io.confluent.ksql.parser.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.parser.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.parser.tree.StringLiteral in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatLogicalBinaryExpression.
@Test
public void shouldFormatLogicalBinaryExpression() {
final LogicalBinaryExpression expression = new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND, new StringLiteral("a"), new StringLiteral("b"));
assertThat(ExpressionFormatter.formatExpression(expression), equalTo("('a' AND 'b')"));
}
use of io.confluent.ksql.parser.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.parser.tree.StringLiteral in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatFunctionWithDistinct.
@Test
public void shouldFormatFunctionWithDistinct() {
final FunctionCall functionCall = new FunctionCall(new NodeLocation(1, 1), QualifiedName.of("function", "COUNT"), true, Collections.singletonList(new StringLiteral("name")));
assertThat(ExpressionFormatter.formatExpression(functionCall), equalTo("function.COUNT(DISTINCT 'name')"));
}
Aggregations