Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

Expand Down Expand Up @@ -121,12 +122,14 @@ public BytecodeNode visitCall(CallExpression call, Context context)
RowExpression function = getSqlFunctionRowExpression(functionMetadata, functionImplementation, metadata, sqlFunctionProperties, call.getArguments());

// Pre-compile lambda bytecode
ImmutableMap.Builder<LambdaDefinitionExpression, LambdaBytecodeGenerator.CompiledLambda> newCompiledLambdaMap = ImmutableMap.builder();
newCompiledLambdaMap.putAll(compiledLambdaMap);
newCompiledLambdaMap.putAll(generateMethodsForLambda(classDefinition, callSiteBinder, cachedInstanceBinder, function, metadata, sqlFunctionProperties, "sql"));
// When we inline the input parameters, if the parameter contains lambda, that lambda has already been pre-compiled and exist in compiledLambdaMap. When we pre-compile the function
// it would be compiled again. Do not put these in the new map in this case.
Map<LambdaDefinitionExpression, LambdaBytecodeGenerator.CompiledLambda> newCompiledLambdaMap = new HashMap<>(compiledLambdaMap);
generateMethodsForLambda(classDefinition, callSiteBinder, cachedInstanceBinder, function, metadata, sqlFunctionProperties, "sql")
.forEach(newCompiledLambdaMap::putIfAbsent);

// generate bytecode for SQL function
RowExpressionCompiler newRowExpressionCompiler = new RowExpressionCompiler(classDefinition, callSiteBinder, cachedInstanceBinder, fieldReferenceCompiler, metadata, sqlFunctionProperties, newCompiledLambdaMap.build());
RowExpressionCompiler newRowExpressionCompiler = new RowExpressionCompiler(classDefinition, callSiteBinder, cachedInstanceBinder, fieldReferenceCompiler, metadata, sqlFunctionProperties, ImmutableMap.copyOf(newCompiledLambdaMap));
// If called on null input, directly use the generated bytecode
if (functionMetadata.isCalledOnNullInput() || call.getArguments().isEmpty()) {
return newRowExpressionCompiler.compile(
Expand Down