Search in sources :

Example 1 with NodeLocation

use of io.confluent.ksql.parser.tree.NodeLocation 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')"));
}
Also used : NodeLocation(io.confluent.ksql.parser.tree.NodeLocation) StringLiteral(io.confluent.ksql.parser.tree.StringLiteral) FunctionCall(io.confluent.ksql.parser.tree.FunctionCall) Test(org.junit.Test)

Example 2 with NodeLocation

use of io.confluent.ksql.parser.tree.NodeLocation 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 ) "));
}
Also used : Window(io.confluent.ksql.parser.tree.Window) NodeLocation(io.confluent.ksql.parser.tree.NodeLocation) StringLiteral(io.confluent.ksql.parser.tree.StringLiteral) WindowExpression(io.confluent.ksql.parser.tree.WindowExpression) TumblingWindowExpression(io.confluent.ksql.parser.tree.TumblingWindowExpression) HoppingWindowExpression(io.confluent.ksql.parser.tree.HoppingWindowExpression) FunctionCall(io.confluent.ksql.parser.tree.FunctionCall) TumblingWindowExpression(io.confluent.ksql.parser.tree.TumblingWindowExpression) Test(org.junit.Test)

Aggregations

FunctionCall (io.confluent.ksql.parser.tree.FunctionCall)2 NodeLocation (io.confluent.ksql.parser.tree.NodeLocation)2 StringLiteral (io.confluent.ksql.parser.tree.StringLiteral)2 Test (org.junit.Test)2 HoppingWindowExpression (io.confluent.ksql.parser.tree.HoppingWindowExpression)1 TumblingWindowExpression (io.confluent.ksql.parser.tree.TumblingWindowExpression)1 Window (io.confluent.ksql.parser.tree.Window)1 WindowExpression (io.confluent.ksql.parser.tree.WindowExpression)1