use of io.confluent.ksql.parser.tree.LongLiteral in project ksql by confluentinc.
the class QueryAnalyzerTest method shouldProcessHavingExpression.
@Test
public void shouldProcessHavingExpression() {
final List<Statement> statements = ksqlParser.buildAst("select itemid, sum(orderunits) from orders window TUMBLING ( size 30 second) " + "where orderunits > 5 group by itemid having count(itemid) > 10;", metaStore);
final Query query = (Query) statements.get(0);
final Analysis analysis = queryAnalyzer.analyze("sqlExpression", query);
final AggregateAnalysis aggregateAnalysis = queryAnalyzer.analyzeAggregate(query, analysis);
final Expression havingExpression = aggregateAnalysis.getHavingExpression();
assertThat(havingExpression, equalTo(new ComparisonExpression(ComparisonExpression.Type.GREATER_THAN, new QualifiedNameReference(QualifiedName.of("KSQL_AGG_VARIABLE_1")), new LongLiteral("10"))));
}
use of io.confluent.ksql.parser.tree.LongLiteral in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatBetweenPredicate.
@Test
public void shouldFormatBetweenPredicate() {
final BetweenPredicate predicate = new BetweenPredicate(new StringLiteral("blah"), new LongLiteral("5"), new LongLiteral("10"));
assertThat(ExpressionFormatter.formatExpression(predicate), equalTo("('blah' BETWEEN 5 AND 10)"));
}
use of io.confluent.ksql.parser.tree.LongLiteral in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatSimpleCaseExpression.
@Test
public void shouldFormatSimpleCaseExpression() {
final SimpleCaseExpression expression = new SimpleCaseExpression(new StringLiteral("operand"), Collections.singletonList(new WhenClause(new StringLiteral("foo"), new LongLiteral("1"))), Optional.empty());
assertThat(ExpressionFormatter.formatExpression(expression), equalTo("(CASE 'operand' WHEN 'foo' THEN 1 END)"));
}
use of io.confluent.ksql.parser.tree.LongLiteral 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.LongLiteral 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)"));
}
Aggregations