use of io.confluent.ksql.execution.expression.tree.LambdaFunctionCall in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatLambdaExpression.
@Test
public void shouldFormatLambdaExpression() {
// Given:
final LambdaFunctionCall expression = new LambdaFunctionCall(Optional.of(LOCATION), ImmutableList.of("X", "Y"), new LogicalBinaryExpression(LogicalBinaryExpression.Type.OR, new LambdaVariable("X"), new LambdaVariable("Y")));
// When:
final String text = ExpressionFormatter.formatExpression(expression);
// Then:
assertThat(text, equalTo("(X, Y) => (X OR Y)"));
}
use of io.confluent.ksql.execution.expression.tree.LambdaFunctionCall in project ksql by confluentinc.
the class AstBuilderTest method shouldBuildNestedLambdaFunction.
@Test
public void shouldBuildNestedLambdaFunction() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT TRANSFORM_ARRAY(Col4, (X,Y) => TRANSFORM_ARRAY(Col4, X => 5)) FROM TEST1;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat(result.getSelect(), is(new Select(ImmutableList.of(new SingleColumn(new FunctionCall(FunctionName.of("TRANSFORM_ARRAY"), ImmutableList.of(column("COL4"), new LambdaFunctionCall(ImmutableList.of("X", "Y"), new FunctionCall(FunctionName.of("TRANSFORM_ARRAY"), ImmutableList.of(column("COL4"), new LambdaFunctionCall(ImmutableList.of("X"), new IntegerLiteral(5))))))), Optional.empty())))));
}
Aggregations