1#include "duckdb/function/udf_function.hpp"
2
3#include "duckdb/parser/parsed_data/create_scalar_function_info.hpp"
4#include "duckdb/parser/parsed_data/create_aggregate_function_info.hpp"
5
6#include "duckdb/main/client_context.hpp"
7
8namespace duckdb {
9
10void UDFWrapper::RegisterFunction(string name, vector<LogicalType> args, LogicalType ret_type,
11 scalar_function_t udf_function, ClientContext &context, LogicalType varargs) {
12
13 ScalarFunction scalar_function(std::move(name), std::move(args), std::move(ret_type), std::move(udf_function));
14 scalar_function.varargs = std::move(varargs);
15 scalar_function.null_handling = FunctionNullHandling::SPECIAL_HANDLING;
16 CreateScalarFunctionInfo info(scalar_function);
17 info.schema = DEFAULT_SCHEMA;
18 context.RegisterFunction(info);
19}
20
21void UDFWrapper::RegisterAggrFunction(AggregateFunction aggr_function, ClientContext &context, LogicalType varargs) {
22 aggr_function.varargs = std::move(varargs);
23 CreateAggregateFunctionInfo info(std::move(aggr_function));
24 context.RegisterFunction(info);
25}
26
27} // namespace duckdb
28