use of io.confluent.ksql.parser.tree.WindowExpression in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatFunctionCallWithWindow.
@Test
public void shouldFormatFunctionCallWithWindow() {
final FunctionCall functionCall = new FunctionCall(new NodeLocation(1, 1), QualifiedName.of("function"), Optional.of(new Window("window", new WindowExpression("blah", new TumblingWindowExpression(1L, TimeUnit.SECONDS)))), false, Collections.singletonList(new StringLiteral("name")));
assertThat(ExpressionFormatter.formatExpression(functionCall), equalTo("function('name') OVER WINDOW WINDOW blah TUMBLING ( SIZE 1 SECONDS ) "));
}
use of io.confluent.ksql.parser.tree.WindowExpression in project ksql by confluentinc.
the class AstBuilder method visitWindowExpression.
@Override
public Node visitWindowExpression(SqlBaseParser.WindowExpressionContext ctx) {
String windowName = DEFAULT_WINDOW_NAME;
if (ctx.IDENTIFIER() != null) {
windowName = ctx.IDENTIFIER().getText();
}
windowName = windowName.toUpperCase();
if (ctx.tumblingWindowExpression() != null) {
TumblingWindowExpression tumblingWindowExpression = (TumblingWindowExpression) visitTumblingWindowExpression(ctx.tumblingWindowExpression());
return new WindowExpression(windowName, tumblingWindowExpression);
} else if (ctx.hoppingWindowExpression() != null) {
HoppingWindowExpression hoppingWindowExpression = (HoppingWindowExpression) visitHoppingWindowExpression(ctx.hoppingWindowExpression());
return new WindowExpression(windowName, hoppingWindowExpression);
} else if (ctx.sessionWindowExpression() != null) {
SessionWindowExpression sessionWindowExpression = (SessionWindowExpression) visitSessionWindowExpression(ctx.sessionWindowExpression());
return new WindowExpression(windowName, sessionWindowExpression);
}
throw new KsqlException("Window description is not correct.");
}
Aggregations