use of com.facebook.presto.sql.tree.LambdaExpression in project presto by prestodb.
the class TestSqlParser method testLambda.
@Test
public void testLambda() throws Exception {
assertExpression("x -> sin(x)", new LambdaExpression(ImmutableList.of(new LambdaArgumentDeclaration("x")), new FunctionCall(QualifiedName.of("sin"), ImmutableList.of(new Identifier("x")))));
assertExpression("(x, y) -> mod(x, y)", new LambdaExpression(ImmutableList.of(new LambdaArgumentDeclaration("x"), new LambdaArgumentDeclaration("y")), new FunctionCall(QualifiedName.of("mod"), ImmutableList.of(new Identifier("x"), new Identifier("y")))));
}
use of com.facebook.presto.sql.tree.LambdaExpression in project presto by prestodb.
the class AstBuilder method visitLambda.
@Override
public Node visitLambda(SqlBaseParser.LambdaContext context) {
List<LambdaArgumentDeclaration> arguments = context.identifier().stream().map(SqlBaseParser.IdentifierContext::getText).map(LambdaArgumentDeclaration::new).collect(toList());
Expression body = (Expression) visit(context.expression());
return new LambdaExpression(arguments, body);
}
Aggregations