use of io.confluent.ksql.parser.tree.LongLiteral 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.LongLiteral in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatRow.
@Test
public void shouldFormatRow() {
final String result = ExpressionFormatter.formatExpression(new Row(Arrays.asList(new LongLiteral("1"), new QualifiedNameReference(QualifiedName.of(Arrays.asList("a", "b"))))));
assertThat(result, equalTo("ROW (1, a.b)"));
}
use of io.confluent.ksql.parser.tree.LongLiteral in project ksql by confluentinc.
the class AstBuilder method visitPrintTopic.
@Override
public Node visitPrintTopic(SqlBaseParser.PrintTopicContext context) {
boolean fromBeginning = context.FROM() != null;
QualifiedName topicName = null;
if (context.STRING() != null) {
topicName = QualifiedName.of(unquote(context.STRING().getText(), "'"));
} else {
topicName = getQualifiedName(context.qualifiedName());
}
if (context.number() == null) {
return new PrintTopic(getLocation(context), topicName, fromBeginning, null);
} else if (context.number() instanceof SqlBaseParser.IntegerLiteralContext) {
SqlBaseParser.IntegerLiteralContext integerLiteralContext = (SqlBaseParser.IntegerLiteralContext) context.number();
return new PrintTopic(getLocation(context), topicName, fromBeginning, (LongLiteral) visitIntegerLiteral(integerLiteralContext));
} else {
throw new KsqlException("Interval value should be integer in 'PRINT' command!");
}
}
Aggregations