|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once |
|
|
|
#include "arrow/compute/exec.h" |
|
#include "arrow/compute/function.h" |
|
#include "arrow/compute/registry.h" |
|
#include "arrow/python/platform.h" |
|
#include "arrow/record_batch.h" |
|
#include "arrow/util/iterator.h" |
|
|
|
#include "arrow/python/common.h" |
|
#include "arrow/python/pyarrow.h" |
|
#include "arrow/python/visibility.h" |
|
|
|
namespace arrow { |
|
|
|
namespace py { |
|
|
|
|
|
|
|
|
|
struct ARROW_PYTHON_EXPORT UdfOptions { |
|
std::string func_name; |
|
compute::Arity arity; |
|
compute::FunctionDoc func_doc; |
|
std::vector<std::shared_ptr<DataType>> input_types; |
|
std::shared_ptr<DataType> output_type; |
|
}; |
|
|
|
|
|
struct ARROW_PYTHON_EXPORT UdfContext { |
|
MemoryPool* pool; |
|
int64_t batch_length; |
|
}; |
|
|
|
using UdfWrapperCallback = std::function<PyObject*( |
|
PyObject* user_function, const UdfContext& context, PyObject* inputs)>; |
|
|
|
|
|
Status ARROW_PYTHON_EXPORT RegisterScalarFunction( |
|
PyObject* user_function, UdfWrapperCallback wrapper, const UdfOptions& options, |
|
compute::FunctionRegistry* registry = NULLPTR); |
|
|
|
|
|
Status ARROW_PYTHON_EXPORT RegisterTabularFunction( |
|
PyObject* user_function, UdfWrapperCallback wrapper, const UdfOptions& options, |
|
compute::FunctionRegistry* registry = NULLPTR); |
|
|
|
|
|
Status ARROW_PYTHON_EXPORT RegisterAggregateFunction( |
|
PyObject* user_function, UdfWrapperCallback wrapper, const UdfOptions& options, |
|
compute::FunctionRegistry* registry = NULLPTR); |
|
|
|
|
|
Status ARROW_PYTHON_EXPORT RegisterVectorFunction( |
|
PyObject* user_function, UdfWrapperCallback wrapper, const UdfOptions& options, |
|
compute::FunctionRegistry* registry = NULLPTR); |
|
|
|
Result<std::shared_ptr<RecordBatchReader>> ARROW_PYTHON_EXPORT |
|
CallTabularFunction(const std::string& func_name, const std::vector<Datum>& args, |
|
compute::FunctionRegistry* registry = NULLPTR); |
|
|
|
} |
|
|
|
} |
|
|