Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
db634fb
updating submodule
vibhatha Mar 4, 2022
9ad5c8f
temp commit to remove files in submodule
vibhatha Mar 19, 2022
12010e8
adding submodule
vibhatha Mar 19, 2022
d7c4593
updating testing submodule
vibhatha Mar 20, 2022
2a2ec21
revert to uupstream version
vibhatha Mar 20, 2022
7aa5fc4
nltk example step 1
vibhatha Jan 31, 2022
994b629
rebase
vibhatha Feb 8, 2022
86632be
function registry example enhanced for udf implementation
vibhatha Feb 9, 2022
c49ece3
adding udf poc interfaces
vibhatha Feb 10, 2022
f2f35cb
testing udf
vibhatha Feb 11, 2022
5598cdc
adding cpp interfaces in cython and creating a basic UDF synthesizer
vibhatha Feb 14, 2022
dc9c8df
adding cython binding for funcptr init
vibhatha Feb 15, 2022
e5dc4b3
initial version of function registry WIP
vibhatha Feb 15, 2022
dc15bda
updating call back API
vibhatha Feb 15, 2022
78ca0a9
func registry with a cython udf
vibhatha Feb 17, 2022
9531409
testing udf python expose
vibhatha Feb 18, 2022
7400faf
initial version of end-to-end pycallable
vibhatha Feb 21, 2022
5ec38ed
adding and end-to-end udf for scalar array
vibhatha Feb 21, 2022
bd3f1ce
reformat
vibhatha Feb 21, 2022
9f5e865
minor changes
vibhatha Feb 24, 2022
6d98c17
removing inspect func
vibhatha Feb 25, 2022
b4a8fd3
cleaning up the current python API
vibhatha Feb 25, 2022
e13259e
cleaning up the current code
vibhatha Feb 25, 2022
541fffd
temp checkin
vibhatha Feb 25, 2022
82b71b7
minor changes
vibhatha Mar 3, 2022
c31ccc1
updating cmakelist
vibhatha Mar 4, 2022
92caca7
updating cmakelist(examples)
vibhatha Mar 4, 2022
1ff043f
minor fix for python
vibhatha Mar 4, 2022
460e2c9
refactor code v1
vibhatha Mar 5, 2022
a82ecd9
adding scalar unary and array unary ops
vibhatha Mar 7, 2022
846cb6c
adding initial macro component
vibhatha Mar 9, 2022
2ef0e9b
adding exceptions and refactor
vibhatha Mar 9, 2022
c238ba1
updating example
vibhatha Mar 9, 2022
7e0ea90
moved udf example
vibhatha Mar 9, 2022
a987068
fix varargs function registration issue
vibhatha Mar 10, 2022
f73fe0c
fix memory issue
vibhatha Mar 11, 2022
e839616
adding udf example
vibhatha Mar 11, 2022
35a94c2
refactor code and adding python test cases
vibhatha Mar 14, 2022
f1f9687
cleaning up udf C++ example
vibhatha Mar 14, 2022
534592e
cleaning up examples cmake file
vibhatha Mar 14, 2022
a7abaf8
cleaning up temp test
vibhatha Mar 14, 2022
bff2be8
reformat tests
vibhatha Mar 14, 2022
b2df0c3
cleaning code
vibhatha Mar 14, 2022
4c6efc2
acleaning spacing
vibhatha Mar 14, 2022
286629e
adding doc string for registration function
vibhatha Mar 14, 2022
facf36b
update function call
vibhatha Mar 14, 2022
d8ac3a6
updating registration code
vibhatha Mar 14, 2022
06e042d
refactor python bindings and func docs
vibhatha Mar 14, 2022
a35066f
addressing reviews
vibhatha Mar 28, 2022
427ef1d
adding test cases for negative cases
vibhatha Mar 28, 2022
bd1e74b
fixing an issue in func docs passing
vibhatha Mar 28, 2022
be1e59f
minor check for appveyour
vibhatha Mar 28, 2022
a9228e9
removing aggregate example
vibhatha Mar 31, 2022
a34a455
addressing reviews on udf example
vibhatha Mar 31, 2022
09d126b
addressing reviews p1
vibhatha Mar 31, 2022
113d35f
addressing reviews p2
vibhatha Mar 31, 2022
1b8183a
fixing a typo
vibhatha Mar 31, 2022
58e8b90
fixing typo
vibhatha Mar 31, 2022
9c68525
fixing a formatting typo
vibhatha Mar 31, 2022
0eff947
removing custom exceptions
vibhatha Mar 31, 2022
493426d
cmake formatting
vibhatha Mar 31, 2022
24c1d40
removing arity python interface
vibhatha Apr 1, 2022
20ebc30
refactor the udf builder API and add options
vibhatha Apr 1, 2022
6d0215f
rebase
vibhatha Apr 2, 2022
1247558
addressing reviews on function docs, and api modifications
vibhatha Apr 3, 2022
e327e4a
reformatting python docs and testing output type of udf execution
vibhatha Apr 4, 2022
3f35820
removing udf example
vibhatha Apr 4, 2022
221700d
format doc strings
vibhatha Apr 4, 2022
2a2d649
refactor util functions and docstrings
vibhatha Apr 4, 2022
323e845
updating test cases
vibhatha Apr 4, 2022
f8be4c7
updating test case format
vibhatha Apr 4, 2022
5f537e3
updating capture clause for udf caller
vibhatha Apr 5, 2022
707b910
adding function input validation
vibhatha Apr 5, 2022
9eba9cb
updating function signature and usage
vibhatha Apr 5, 2022
24fdd31
adding validation and test cases
vibhatha Apr 5, 2022
7a17d02
adding doc check test cases
vibhatha Apr 6, 2022
5769f49
updating test cases
vibhatha Apr 6, 2022
228d43a
updating udf c++ kernel usage
vibhatha Apr 6, 2022
60bfd7f
refactor test suite
vibhatha Apr 6, 2022
545925d
simplifying udf options and fix arity usage
vibhatha Apr 7, 2022
b47924a
removing num_args and updating test cases
vibhatha Apr 7, 2022
4566078
refactor test cases exception message validation
vibhatha Apr 7, 2022
0158514
updating function doc usage and input type usage in function registra…
vibhatha Apr 7, 2022
91a410b
adding validation for output type
vibhatha Apr 11, 2022
df99ace
doc format and add python error check
vibhatha Apr 11, 2022
31a9ae4
adding todo docstring and add python check error
vibhatha Apr 11, 2022
9056a0a
formatting exception messages
vibhatha Apr 12, 2022
27b55cb
addressing reviews
vibhatha Apr 12, 2022
440e19f
func doc usage fix
vibhatha Apr 13, 2022
e21c82d
fcleaning up the udf builder into a plain function
vibhatha Apr 13, 2022
5ec35ca
cleaning unused element
vibhatha Apr 14, 2022
5b2c982
address minor issues in formatting and usage in tests
vibhatha Apr 18, 2022
196b66e
update documentation for InputType funcs
vibhatha Apr 18, 2022
6aed6ad
minor documentation fix
vibhatha Apr 18, 2022
22a48de
remove const
vibhatha Apr 19, 2022
dfa60bd
update function args
vibhatha Apr 19, 2022
ac844e1
update test case and validations for output types
vibhatha Apr 19, 2022
5dfe7ea
update test cases and usage
vibhatha Apr 19, 2022
086d803
fixing a memory issue and adding strongly typed function API
vibhatha Apr 20, 2022
a2c309e
fixing error messages, updating test cases
vibhatha Apr 20, 2022
bc1953c
minor change to error message
vibhatha Apr 20, 2022
34238ca
adding context to udfs
vibhatha Apr 20, 2022
a52b8dd
adding documentation for scalar udf context
vibhatha Apr 20, 2022
88bf789
minor formatting
vibhatha Apr 20, 2022
869b0fb
addressing code doc reviews
vibhatha Apr 21, 2022
49441c9
updating test cases with fixtures and updating memory pool example
vibhatha Apr 22, 2022
eb6aaf4
updating validity scalar class
vibhatha Apr 22, 2022
3023124
converting scalar udf options to a struct
vibhatha Apr 22, 2022
5a3ff2e
refactor the test suite for fixture usage in registration
vibhatha Apr 26, 2022
30b2f8f
removing the risky usage of memory pool
vibhatha Apr 26, 2022
494f610
remove InputType and update correspondeces
vibhatha Apr 26, 2022
bc91482
format test cases
vibhatha Apr 26, 2022
2358a95
addressed minor nits and formatting
vibhatha Apr 26, 2022
d54da8b
addressing review comments
vibhatha Apr 27, 2022
39a9cae
minor changes
vibhatha Apr 27, 2022
e48b94c
addressing missed pr feedback
vibhatha Apr 28, 2022
47329ec
minor modifications
vibhatha Apr 28, 2022
0d1a1a8
updating docstrings of scalar function registration
vibhatha Apr 28, 2022
0f03d1f
fixed typo on input_types doctoring
vibhatha Apr 28, 2022
f294d53
addressing review comments
vibhatha Apr 28, 2022
705e4df
fixed the definition for batch_length extraction
vibhatha Apr 28, 2022
0ca7303
fixing a typo
vibhatha Apr 28, 2022
8208ace
added a missing move op
vibhatha Apr 30, 2022
29b5121
minor nit
vibhatha Apr 30, 2022
c961c4e
Update cpp/src/arrow/compute/function.h
vibhatha Apr 30, 2022
fc354e2
Apply suggestions from code review
vibhatha Apr 30, 2022
8425e57
addressing reviews
vibhatha Apr 30, 2022
eef3896
avoid a copying input types
vibhatha Apr 30, 2022
a51a6a0
addressing move issue
vibhatha Apr 30, 2022
706087a
Fix Python reference leaks and improve tests
pitrou May 2, 2022
08880e7
Fix subtract_checked doc
pitrou May 2, 2022
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
3 changes: 3 additions & 0 deletions cpp/examples/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,7 @@ if(ARROW_PARQUET AND ARROW_DATASET)

add_arrow_example(join_example EXTRA_LINK_LIBS ${DATASET_EXAMPLES_LINK_LIBS})
add_dependencies(join-example parquet)

add_arrow_example(udf_example)

endif()
2 changes: 1 addition & 1 deletion cpp/examples/arrow/compute_register_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const cp::FunctionDoc func_doc{

int main(int argc, char** argv) {
const std::string name = "compute_register_example";
auto func = std::make_shared<cp::ScalarFunction>(name, cp::Arity::Unary(), &func_doc);
auto func = std::make_shared<cp::ScalarFunction>(name, cp::Arity::Unary(), func_doc);
cp::ScalarKernel kernel({cp::InputType::Array(arrow::int64())}, arrow::int64(),
ExampleFunctionImpl);
kernel.mem_allocation = cp::MemAllocation::NO_PREALLOCATE;
Expand Down
103 changes: 103 additions & 0 deletions cpp/examples/arrow/udf_example.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

#include <arrow/api.h>
#include <arrow/compute/api.h>

#include <cstdlib>
#include <iostream>
#include <memory>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>

// Demonstrate registering a user-defined Arrow compute function outside of the Arrow
// source tree

namespace cp = ::arrow::compute;

#define ABORT_ON_FAILURE(expr) \
do { \
arrow::Status status_ = (expr); \
if (!status_.ok()) { \
std::cerr << status_.message() << std::endl; \
abort(); \
} \
} while (0);

template <typename TYPE,
typename = typename std::enable_if<arrow::is_number_type<TYPE>::value |
arrow::is_boolean_type<TYPE>::value |
arrow::is_temporal_type<TYPE>::value>::type>
arrow::Result<std::shared_ptr<arrow::Array>> GetArrayDataSample(
const std::vector<typename TYPE::c_type>& values) {
using ArrowBuilderType = typename arrow::TypeTraits<TYPE>::BuilderType;
ArrowBuilderType builder;
ARROW_RETURN_NOT_OK(builder.Reserve(values.size()));
ARROW_RETURN_NOT_OK(builder.AppendValues(values));
return builder.Finish();
}

const cp::FunctionDoc func_doc{
"User-defined-function usage to demonstrate registering an out-of-tree function",
"returns x + y + z",
{"x", "y", "z"},
"UDFOptions"};

arrow::Status SampleFunction(cp::KernelContext* ctx, const cp::ExecBatch& batch,
arrow::Datum* out) {
// temp = x + y; return temp + z
ARROW_ASSIGN_OR_RAISE(auto temp, cp::CallFunction("add", {batch[0], batch[1]}));
return cp::CallFunction("add", {temp, batch[2]}).Value(out);
}

arrow::Status Execute() {
const std::string name = "add_three";
auto func = std::make_shared<cp::ScalarFunction>(name, cp::Arity::Ternary(), func_doc);
cp::ScalarKernel kernel(
{cp::InputType::Array(arrow::int64()), cp::InputType::Array(arrow::int64()),
cp::InputType::Array(arrow::int64())},
arrow::int64(), SampleFunction);

kernel.mem_allocation = cp::MemAllocation::NO_PREALLOCATE;
kernel.null_handling = cp::NullHandling::COMPUTED_NO_PREALLOCATE;

ARROW_RETURN_NOT_OK(func->AddKernel(std::move(kernel)));

auto registry = cp::GetFunctionRegistry();
ARROW_RETURN_NOT_OK(registry->AddFunction(std::move(func)));

ARROW_ASSIGN_OR_RAISE(auto x, GetArrayDataSample<arrow::Int64Type>({1, 2, 3}));
ARROW_ASSIGN_OR_RAISE(auto y, GetArrayDataSample<arrow::Int64Type>({4, 5, 6}));
ARROW_ASSIGN_OR_RAISE(auto z, GetArrayDataSample<arrow::Int64Type>({7, 8, 9}));

ARROW_ASSIGN_OR_RAISE(auto res, cp::CallFunction(name, {x, y, z}));
auto res_array = res.make_array();
std::cout << "Result" << std::endl;
std::cout << res_array->ToString() << std::endl;
return arrow::Status::OK();
}

int main(int argc, char** argv) {
auto status = Execute();
if (!status.ok()) {
std::cerr << "Error occurred : " << status.message() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
4 changes: 2 additions & 2 deletions cpp/src/arrow/compute/cast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const FunctionDoc cast_doc{"Cast values to another data type",
// to the standard SQL CAST(expr AS target_type)
class CastMetaFunction : public MetaFunction {
public:
CastMetaFunction() : MetaFunction("cast", Arity::Unary(), &cast_doc) {}
CastMetaFunction() : MetaFunction("cast", Arity::Unary(), cast_doc) {}

Result<const CastOptions*> ValidateOptions(const FunctionOptions* options) const {
auto cast_options = static_cast<const CastOptions*>(options);
Expand Down Expand Up @@ -153,7 +153,7 @@ CastOptions::CastOptions(bool safe)
constexpr char CastOptions::kTypeName[];

CastFunction::CastFunction(std::string name, Type::type out_type_id)
: ScalarFunction(std::move(name), Arity::Unary(), /*doc=*/nullptr),
: ScalarFunction(std::move(name), Arity::Unary(), FunctionDoc::Empty()),
out_type_id_(out_type_id) {}

Status CastFunction::AddKernel(Type::type in_type_id, ScalarKernel kernel) {
Expand Down
18 changes: 9 additions & 9 deletions cpp/src/arrow/compute/exec_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,8 @@ class TestCallScalarFunction : public TestComputeInternals {

// This function simply copies memory from the input argument into the
// (preallocated) output
auto func =
std::make_shared<ScalarFunction>("test_copy", Arity::Unary(), /*doc=*/nullptr);
auto func = std::make_shared<ScalarFunction>("test_copy", Arity::Unary(),
/*doc=*/FunctionDoc::Empty());

// Add a few kernels. Our implementation only accepts arrays
ASSERT_OK(func->AddKernel({InputType::Array(uint8())}, uint8(), ExecCopy));
Expand All @@ -691,8 +691,8 @@ class TestCallScalarFunction : public TestComputeInternals {
ASSERT_OK(registry->AddFunction(func));

// A version which doesn't want the executor to call PropagateNulls
auto func2 = std::make_shared<ScalarFunction>("test_copy_computed_bitmap",
Arity::Unary(), /*doc=*/nullptr);
auto func2 = std::make_shared<ScalarFunction>(
"test_copy_computed_bitmap", Arity::Unary(), /*doc=*/FunctionDoc::Empty());
ScalarKernel kernel({InputType::Array(uint8())}, uint8(), ExecComputedBitmap);
kernel.null_handling = NullHandling::COMPUTED_PREALLOCATE;
ASSERT_OK(func2->AddKernel(kernel));
Expand All @@ -705,9 +705,9 @@ class TestCallScalarFunction : public TestComputeInternals {
// A function that allocates its own output memory. We have cases for both
// non-preallocated data and non-preallocated validity bitmap
auto f1 = std::make_shared<ScalarFunction>("test_nopre_data", Arity::Unary(),
/*doc=*/nullptr);
auto f2 = std::make_shared<ScalarFunction>("test_nopre_validity_or_data",
Arity::Unary(), /*doc=*/nullptr);
/*doc=*/FunctionDoc::Empty());
auto f2 = std::make_shared<ScalarFunction>(
"test_nopre_validity_or_data", Arity::Unary(), /*doc=*/FunctionDoc::Empty());

ScalarKernel kernel({InputType::Array(uint8())}, uint8(), ExecNoPreallocatedData);
kernel.mem_allocation = MemAllocation::NO_PREALLOCATE;
Expand All @@ -727,7 +727,7 @@ class TestCallScalarFunction : public TestComputeInternals {
// This function's behavior depends on a static parameter that is made
// available to the kernel's execution function through its Options object
auto func = std::make_shared<ScalarFunction>("test_stateful", Arity::Unary(),
/*doc=*/nullptr);
/*doc=*/FunctionDoc::Empty());

ScalarKernel kernel({InputType::Array(int32())}, int32(), ExecStateful, InitStateful);
ASSERT_OK(func->AddKernel(kernel));
Expand All @@ -738,7 +738,7 @@ class TestCallScalarFunction : public TestComputeInternals {
auto registry = GetFunctionRegistry();

auto func = std::make_shared<ScalarFunction>("test_scalar_add_int32", Arity::Binary(),
/*doc=*/nullptr);
/*doc=*/FunctionDoc::Empty());
ASSERT_OK(func->AddKernel({InputType::Scalar(int32()), InputType::Scalar(int32())},
int32(), ExecAddInt32));
ASSERT_OK(registry->AddFunction(func));
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/compute/function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ Status ValidateFunctionDescription(const std::string& s) {
} // namespace

Status Function::Validate() const {
if (!doc_->summary.empty()) {
if (!doc_.summary.empty()) {
// Documentation given, check its contents
int arg_count = static_cast<int>(doc_->arg_names.size());
int arg_count = static_cast<int>(doc_.arg_names.size());
// Some varargs functions allow 0 vararg, others expect at least 1,
// hence the two possible values below.
bool arg_count_match = (arg_count == arity_.num_args) ||
Expand All @@ -302,9 +302,9 @@ Status Function::Validate() const {
"In function '", name_,
"': ", "number of argument names for function documentation != function arity");
}
Status st = ValidateFunctionSummary(doc_->summary);
Status st = ValidateFunctionSummary(doc_.summary);
if (st.ok()) {
st &= ValidateFunctionDescription(doc_->description);
st &= ValidateFunctionDescription(doc_.description);
}
if (!st.ok()) {
return st.WithMessage("In function '", name_, "': ", st.message());
Expand Down
47 changes: 25 additions & 22 deletions cpp/src/arrow/compute/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class ARROW_EXPORT Function {
const Arity& arity() const { return arity_; }

/// \brief Return the function documentation
const FunctionDoc& doc() const { return *doc_; }
const FunctionDoc& doc() const { return doc_; }

/// \brief Returns the number of registered kernels for this function.
virtual int num_kernels() const = 0;
Expand Down Expand Up @@ -244,12 +244,12 @@ class ARROW_EXPORT Function {
virtual Status Validate() const;

protected:
Function(std::string name, Function::Kind kind, const Arity& arity,
const FunctionDoc* doc, const FunctionOptions* default_options)
Function(std::string name, Function::Kind kind, const Arity& arity, FunctionDoc doc,
const FunctionOptions* default_options)
: name_(std::move(name)),
kind_(kind),
arity_(arity),
doc_(doc ? doc : &FunctionDoc::Empty()),
doc_(std::move(doc)),
default_options_(default_options) {}

Status CheckArity(const std::vector<InputType>&) const;
Expand All @@ -258,7 +258,7 @@ class ARROW_EXPORT Function {
std::string name_;
Function::Kind kind_;
Arity arity_;
const FunctionDoc* doc_;
const FunctionDoc doc_;
const FunctionOptions* default_options_ = NULLPTR;
};

Expand All @@ -279,9 +279,9 @@ class FunctionImpl : public Function {
int num_kernels() const override { return static_cast<int>(kernels_.size()); }

protected:
FunctionImpl(std::string name, Function::Kind kind, const Arity& arity,
const FunctionDoc* doc, const FunctionOptions* default_options)
: Function(std::move(name), kind, arity, doc, default_options) {}
FunctionImpl(std::string name, Function::Kind kind, const Arity& arity, FunctionDoc doc,
const FunctionOptions* default_options)
: Function(std::move(name), kind, arity, std::move(doc), default_options) {}

std::vector<KernelType> kernels_;
};
Expand All @@ -305,10 +305,10 @@ class ARROW_EXPORT ScalarFunction : public detail::FunctionImpl<ScalarKernel> {
public:
using KernelType = ScalarKernel;

ScalarFunction(std::string name, const Arity& arity, const FunctionDoc* doc,
ScalarFunction(std::string name, const Arity& arity, FunctionDoc doc,
const FunctionOptions* default_options = NULLPTR)
: detail::FunctionImpl<ScalarKernel>(std::move(name), Function::SCALAR, arity, doc,
default_options) {}
: detail::FunctionImpl<ScalarKernel>(std::move(name), Function::SCALAR, arity,
std::move(doc), default_options) {}

/// \brief Add a kernel with given input/output types, no required state
/// initialization, preallocation for fixed-width types, and default null
Expand All @@ -329,10 +329,10 @@ class ARROW_EXPORT VectorFunction : public detail::FunctionImpl<VectorKernel> {
public:
using KernelType = VectorKernel;

VectorFunction(std::string name, const Arity& arity, const FunctionDoc* doc,
VectorFunction(std::string name, const Arity& arity, FunctionDoc doc,
const FunctionOptions* default_options = NULLPTR)
: detail::FunctionImpl<VectorKernel>(std::move(name), Function::VECTOR, arity, doc,
default_options) {}
: detail::FunctionImpl<VectorKernel>(std::move(name), Function::VECTOR, arity,
std::move(doc), default_options) {}

/// \brief Add a simple kernel with given input/output types, no required
/// state initialization, no data preallocation, and no preallocation of the
Expand All @@ -350,10 +350,11 @@ class ARROW_EXPORT ScalarAggregateFunction
public:
using KernelType = ScalarAggregateKernel;

ScalarAggregateFunction(std::string name, const Arity& arity, const FunctionDoc* doc,
ScalarAggregateFunction(std::string name, const Arity& arity, FunctionDoc doc,
const FunctionOptions* default_options = NULLPTR)
: detail::FunctionImpl<ScalarAggregateKernel>(
std::move(name), Function::SCALAR_AGGREGATE, arity, doc, default_options) {}
: detail::FunctionImpl<ScalarAggregateKernel>(std::move(name),
Function::SCALAR_AGGREGATE, arity,
std::move(doc), default_options) {}

/// \brief Add a kernel (function implementation). Returns error if the
/// kernel's signature does not match the function's arity.
Expand All @@ -365,10 +366,11 @@ class ARROW_EXPORT HashAggregateFunction
public:
using KernelType = HashAggregateKernel;

HashAggregateFunction(std::string name, const Arity& arity, const FunctionDoc* doc,
HashAggregateFunction(std::string name, const Arity& arity, FunctionDoc doc,
const FunctionOptions* default_options = NULLPTR)
: detail::FunctionImpl<HashAggregateKernel>(
std::move(name), Function::HASH_AGGREGATE, arity, doc, default_options) {}
: detail::FunctionImpl<HashAggregateKernel>(std::move(name),
Function::HASH_AGGREGATE, arity,
std::move(doc), default_options) {}

/// \brief Add a kernel (function implementation). Returns error if the
/// kernel's signature does not match the function's arity.
Expand All @@ -392,9 +394,10 @@ class ARROW_EXPORT MetaFunction : public Function {
const FunctionOptions* options,
ExecContext* ctx) const = 0;

MetaFunction(std::string name, const Arity& arity, const FunctionDoc* doc,
MetaFunction(std::string name, const Arity& arity, FunctionDoc doc,
const FunctionOptions* default_options = NULLPTR)
: Function(std::move(name), Function::META, arity, doc, default_options) {}
: Function(std::move(name), Function::META, arity, std::move(doc),
default_options) {}
};

/// @}
Expand Down
20 changes: 11 additions & 9 deletions cpp/src/arrow/compute/function_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ TEST(Arity, Basics) {
}

TEST(ScalarFunction, Basics) {
ScalarFunction func("scalar_test", Arity::Binary(), /*doc=*/nullptr);
ScalarFunction varargs_func("varargs_test", Arity::VarArgs(1), /*doc=*/nullptr);
ScalarFunction func("scalar_test", Arity::Binary(), /*doc=*/FunctionDoc::Empty());
ScalarFunction varargs_func("varargs_test", Arity::VarArgs(1),
/*doc=*/FunctionDoc::Empty());

ASSERT_EQ("scalar_test", func.name());
ASSERT_EQ(2, func.arity().num_args);
Expand All @@ -194,8 +195,9 @@ TEST(ScalarFunction, Basics) {
}

TEST(VectorFunction, Basics) {
VectorFunction func("vector_test", Arity::Binary(), /*doc=*/nullptr);
VectorFunction varargs_func("varargs_test", Arity::VarArgs(1), /*doc=*/nullptr);
VectorFunction func("vector_test", Arity::Binary(), /*doc=*/FunctionDoc::Empty());
VectorFunction varargs_func("varargs_test", Arity::VarArgs(1),
/*doc=*/FunctionDoc::Empty());

ASSERT_EQ("vector_test", func.name());
ASSERT_EQ(2, func.arity().num_args);
Expand Down Expand Up @@ -260,15 +262,15 @@ void CheckAddDispatch(FunctionType* func) {
}

TEST(ScalarVectorFunction, DispatchExact) {
ScalarFunction func1("scalar_test", Arity::Binary(), /*doc=*/nullptr);
VectorFunction func2("vector_test", Arity::Binary(), /*doc=*/nullptr);
ScalarFunction func1("scalar_test", Arity::Binary(), /*doc=*/FunctionDoc::Empty());
VectorFunction func2("vector_test", Arity::Binary(), /*doc=*/FunctionDoc::Empty());

CheckAddDispatch(&func1);
CheckAddDispatch(&func2);
}

TEST(ArrayFunction, VarArgs) {
ScalarFunction va_func("va_test", Arity::VarArgs(1), /*doc=*/nullptr);
ScalarFunction va_func("va_test", Arity::VarArgs(1), /*doc=*/FunctionDoc::Empty());

std::vector<InputType> va_args = {int8()};

Expand All @@ -294,7 +296,7 @@ TEST(ArrayFunction, VarArgs) {
}

TEST(ScalarAggregateFunction, Basics) {
ScalarAggregateFunction func("agg_test", Arity::Unary(), /*doc=*/nullptr);
ScalarAggregateFunction func("agg_test", Arity::Unary(), /*doc=*/FunctionDoc::Empty());

ASSERT_EQ("agg_test", func.name());
ASSERT_EQ(1, func.arity().num_args);
Expand All @@ -313,7 +315,7 @@ Status NoopMerge(KernelContext*, const KernelState&, KernelState*) {
Status NoopFinalize(KernelContext*, Datum*) { return Status::OK(); }

TEST(ScalarAggregateFunction, DispatchExact) {
ScalarAggregateFunction func("agg_test", Arity::Unary(), /*doc=*/nullptr);
ScalarAggregateFunction func("agg_test", Arity::Unary(), FunctionDoc::Empty());

std::vector<InputType> in_args = {ValueDescr::Array(int8())};
ScalarAggregateKernel kernel(std::move(in_args), int64(), NoopInit, NoopConsume,
Expand Down
Loading