Search in sources :

Example 1 with LambdaExpression

use of io.confluent.ksql.parser.tree.LambdaExpression in project ksql by confluentinc.

the class ExpressionFormatterTest method shouldFormatLambdaExpression.

@Test
public void shouldFormatLambdaExpression() {
    final LambdaExpression expression = new LambdaExpression(Arrays.asList("a", "b"), new StringLiteral("something"));
    assertThat(ExpressionFormatter.formatExpression(expression), equalTo("(a, b) -> 'something'"));
}
Also used : StringLiteral(io.confluent.ksql.parser.tree.StringLiteral) LambdaExpression(io.confluent.ksql.parser.tree.LambdaExpression) Test(org.junit.Test)

Example 2 with LambdaExpression

use of io.confluent.ksql.parser.tree.LambdaExpression in project ksql by confluentinc.

the class AstBuilder method visitLambda.

@Override
public Node visitLambda(SqlBaseParser.LambdaContext context) {
    List<String> arguments = context.identifier().stream().map(AstBuilder::getIdentifierText).collect(toList());
    Expression body = (Expression) visit(context.expression());
    return new LambdaExpression(arguments, body);
}
Also used : InListExpression(io.confluent.ksql.parser.tree.InListExpression) NullIfExpression(io.confluent.ksql.parser.tree.NullIfExpression) SimpleCaseExpression(io.confluent.ksql.parser.tree.SimpleCaseExpression) ComparisonExpression(io.confluent.ksql.parser.tree.ComparisonExpression) DereferenceExpression(io.confluent.ksql.parser.tree.DereferenceExpression) Expression(io.confluent.ksql.parser.tree.Expression) LogicalBinaryExpression(io.confluent.ksql.parser.tree.LogicalBinaryExpression) TumblingWindowExpression(io.confluent.ksql.parser.tree.TumblingWindowExpression) ArithmeticBinaryExpression(io.confluent.ksql.parser.tree.ArithmeticBinaryExpression) NotExpression(io.confluent.ksql.parser.tree.NotExpression) HoppingWindowExpression(io.confluent.ksql.parser.tree.HoppingWindowExpression) SubscriptExpression(io.confluent.ksql.parser.tree.SubscriptExpression) SessionWindowExpression(io.confluent.ksql.parser.tree.SessionWindowExpression) SearchedCaseExpression(io.confluent.ksql.parser.tree.SearchedCaseExpression) LambdaExpression(io.confluent.ksql.parser.tree.LambdaExpression) SubqueryExpression(io.confluent.ksql.parser.tree.SubqueryExpression) WindowExpression(io.confluent.ksql.parser.tree.WindowExpression) ArithmeticUnaryExpression(io.confluent.ksql.parser.tree.ArithmeticUnaryExpression) LambdaExpression(io.confluent.ksql.parser.tree.LambdaExpression)

Aggregations

LambdaExpression (io.confluent.ksql.parser.tree.LambdaExpression)2 ArithmeticBinaryExpression (io.confluent.ksql.parser.tree.ArithmeticBinaryExpression)1 ArithmeticUnaryExpression (io.confluent.ksql.parser.tree.ArithmeticUnaryExpression)1 ComparisonExpression (io.confluent.ksql.parser.tree.ComparisonExpression)1 DereferenceExpression (io.confluent.ksql.parser.tree.DereferenceExpression)1 Expression (io.confluent.ksql.parser.tree.Expression)1 HoppingWindowExpression (io.confluent.ksql.parser.tree.HoppingWindowExpression)1 InListExpression (io.confluent.ksql.parser.tree.InListExpression)1 LogicalBinaryExpression (io.confluent.ksql.parser.tree.LogicalBinaryExpression)1 NotExpression (io.confluent.ksql.parser.tree.NotExpression)1 NullIfExpression (io.confluent.ksql.parser.tree.NullIfExpression)1 SearchedCaseExpression (io.confluent.ksql.parser.tree.SearchedCaseExpression)1 SessionWindowExpression (io.confluent.ksql.parser.tree.SessionWindowExpression)1 SimpleCaseExpression (io.confluent.ksql.parser.tree.SimpleCaseExpression)1 StringLiteral (io.confluent.ksql.parser.tree.StringLiteral)1 SubqueryExpression (io.confluent.ksql.parser.tree.SubqueryExpression)1 SubscriptExpression (io.confluent.ksql.parser.tree.SubscriptExpression)1 TumblingWindowExpression (io.confluent.ksql.parser.tree.TumblingWindowExpression)1 WindowExpression (io.confluent.ksql.parser.tree.WindowExpression)1 Test (org.junit.Test)1