use of io.prestosql.metadata.FunctionAndTypeManager in project hetu-core by openlookeng.
the class StatisticsAggregationPlanner method createAggregation.
private ColumnStatisticsAggregation createAggregation(QualifiedName functionName, SymbolReference input, Type inputType, Type outputType) {
Signature signature = metadata.getFunctionAndTypeManager().resolveBuiltInFunction(functionName, fromTypes(inputType));
FunctionAndTypeManager functionAndTypeManager = metadata.getFunctionAndTypeManager();
FunctionHandle functionHandle = functionAndTypeManager.lookupFunction(functionName.getSuffix(), TypeSignatureProvider.fromTypes(ImmutableList.of(inputType)));
Type resolvedType = metadata.getType(getOnlyElement(signature.getArgumentTypes()));
verify(resolvedType.equals(inputType), "resolved function input type does not match the input type: %s != %s", resolvedType, inputType);
return new ColumnStatisticsAggregation(new AggregationNode.Aggregation(new CallExpression(functionName.getSuffix(), functionHandle, outputType, ImmutableList.of(castToRowExpression(input)), Optional.empty()), ImmutableList.of(castToRowExpression(input)), false, Optional.empty(), Optional.empty(), Optional.empty()), outputType);
}
use of io.prestosql.metadata.FunctionAndTypeManager in project hetu-core by openlookeng.
the class FormatFunction method specialize.
@Override
public BuiltInScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, FunctionAndTypeManager functionAndTypeManager) {
Type rowType = boundVariables.getTypeVariable("T");
List<BiFunction<ConnectorSession, Block, Object>> converters = mapWithIndex(rowType.getTypeParameters().stream(), (type, index) -> converter(functionAndTypeManager, type, toIntExact(index))).collect(toImmutableList());
return new BuiltInScalarFunctionImplementation(false, ImmutableList.of(valueTypeArgumentProperty(RETURN_NULL_ON_NULL), valueTypeArgumentProperty(RETURN_NULL_ON_NULL)), METHOD_HANDLE.bindTo(converters));
}
use of io.prestosql.metadata.FunctionAndTypeManager in project hetu-core by openlookeng.
the class FunctionCallCodeGenerator method generateExpression.
@Override
public BytecodeNode generateExpression(FunctionHandle functionHandle, BytecodeGeneratorContext context, Type returnType, List<RowExpression> arguments) {
FunctionAndTypeManager functionAndTypeManager = context.getFunctionManager();
BuiltInScalarFunctionImplementation function = functionAndTypeManager.getBuiltInScalarFunctionImplementation(functionHandle);
List<BytecodeNode> argumentsBytecode = new ArrayList<>();
for (int i = 0; i < arguments.size(); i++) {
RowExpression argument = arguments.get(i);
BuiltInScalarFunctionImplementation.ArgumentProperty argumentProperty = function.getArgumentProperty(i);
if (argumentProperty.getArgumentType() == VALUE_TYPE) {
argumentsBytecode.add(context.generate(argument));
} else {
argumentsBytecode.add(context.generate(argument, Optional.of(argumentProperty.getLambdaInterface())));
}
}
return context.generateCall(functionAndTypeManager.getFunctionMetadata(functionHandle).getName().getObjectName(), function, argumentsBytecode);
}
Aggregations