use of io.confluent.ksql.execution.interpreter.terms.LambdaFunctionTerms.LambdaFunction2Term in project ksql by confluentinc.
the class TermCompiler method visitLambdaExpression.
@Override
public Term visitLambdaExpression(final LambdaFunctionCall lambdaFunctionCall, final Context context) {
final Term lambdaBody = process(lambdaFunctionCall.getBody(), context);
final ImmutableList.Builder<Pair<String, SqlType>> nameToType = ImmutableList.builder();
for (final String lambdaArg : lambdaFunctionCall.getArguments()) {
nameToType.add(Pair.of(lambdaArg, context.getLambdaSqlTypeMapping().get((lambdaArg))));
}
switch(lambdaFunctionCall.getArguments().size()) {
case 1:
return new LambdaFunction1Term(nameToType.build(), lambdaBody);
case 2:
return new LambdaFunction2Term(nameToType.build(), lambdaBody);
case 3:
return new LambdaFunction3Term(nameToType.build(), lambdaBody);
default:
throw new KsqlException("Interpreter only supports lambdas up to three arguments");
}
}
Aggregations