lidavidm commented on code in PR #12590: URL: https://github.com/apache/arrow/pull/12590#discussion_r856201199
########## cpp/src/arrow/python/udf.h: ########## @@ -0,0 +1,63 @@ +// 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. + +#pragma once + +#include "arrow/python/platform.h" + +#include "arrow/compute/api_scalar.h" +#include "arrow/compute/cast.h" +#include "arrow/compute/exec.h" +#include "arrow/compute/function.h" +#include "arrow/compute/registry.h" + +#include "arrow/python/common.h" +#include "arrow/python/pyarrow.h" +#include "arrow/python/visibility.h" + +namespace arrow { + +namespace py { + +// TODO: TODO(ARROW-16041): UDF Options are not exposed to the Python +// users. This feature will be included when extending to provide advanced +// options for the users. +struct ARROW_PYTHON_EXPORT ScalarUdfOptions { + std::string func_name; + compute::Function::Kind kind = compute::Function::SCALAR; Review Comment: nit, but if this is ScalarUdfOptions and the kind is always scalar, I would drop one or the other (i.e. rename the struct or remove the field) ########## python/pyarrow/compute.py: ########## @@ -76,6 +77,10 @@ get_function, list_functions, _group_by, + # Udf + register_scalar_function, + ScalarUdfContext, + _get_scalar_udf_context, Review Comment: Hmm. Don't expose this. Just make the object constructible from Python. ########## python/pyarrow/_compute.pyx: ########## @@ -2275,3 +2362,214 @@ cdef CExpression _bind(Expression filter, Schema schema) except *: return GetResultValue(filter.unwrap().Bind( deref(pyarrow_unwrap_schema(schema).get()))) + + +cdef class ScalarUdfContext: + """ + Per-invocation function context/state. + + This object will always be the first argument to a user-defined + function. It should not be used outside of a call to the function. + """ + + def __init__(self): + raise TypeError("Do not call {}'s constructor directly" + .format(self.__class__.__name__)) + + cdef void init(self, const CScalarUdfContext &c_context): + self.c_context = c_context + + @property + def batch_length(self): + """ + The common length of all input arguments (int). + + In the case that all arguments are scalars, this value + is used to pass the "actual length" of the arguments, + e.g. because the scalar values are encoding a column + with a constant value. + """ + return self.c_context.batch_length + + @property + def memory_pool(self): + """ + A memory pool for allocations (:class:`MemoryPool`). + """ + return box_memory_pool(self.c_context.pool) + + +cdef inline CFunctionDoc _make_function_doc(dict func_doc) except *: + """ + Helper function to generate the FunctionDoc + This function accepts a dictionary and expect the + summary(str), description(str) and arg_names(List[str]) keys. + """ + cdef: + CFunctionDoc f_doc + vector[c_string] c_arg_names + + f_doc.summary = tobytes(func_doc["summary"]) + f_doc.description = tobytes(func_doc["description"]) + for arg_name in func_doc["arg_names"]: + c_arg_names.push_back(tobytes(arg_name)) + f_doc.arg_names = c_arg_names + # UDFOptions integration: + # TODO: https://issues.apache.org/jira/browse/ARROW-16041 + f_doc.options_class = tobytes("") + f_doc.options_required = False + return f_doc + + +cdef object box_scalar_udf_context(const CScalarUdfContext& c_context): + cdef ScalarUdfContext context = ScalarUdfContext.__new__(ScalarUdfContext) + context.init(c_context) + return context + + +cdef _scalar_udf_callback(user_function, const CScalarUdfContext& c_context, inputs): + """ + Helper callback function used to wrap the ScalarUdfContext from Python to C++ + execution. + """ + context = box_scalar_udf_context(c_context) + return user_function(context, *inputs) + + +def _get_scalar_udf_context(memory_pool, batch_length): + cdef CScalarUdfContext c_context + c_context.pool = maybe_unbox_memory_pool(memory_pool) + c_context.batch_length = batch_length + context = box_scalar_udf_context(c_context) + return context + + +def register_scalar_function(func, func_name, function_doc, in_types, + out_type): + """ + Register a user-defined scalar function. + + A scalar function is a function that executes elementwise + operations on arrays or scalars, and therefore whose results + generally do not depend on the order of the values in the + arguments. Accepts and returns arrays that are all of the + same size. These functions roughly correspond to the functions + used in SQL expressions. + + Parameters + ---------- + func : callable + A callable implementing the user-defined function. + It must take arguments equal to the number of + in_types defined. It must return an Array or Scalar + matching the out_type. It must return a Scalar if + all arguments are scalar, else it must return an Array. + + To define a varargs function, pass a callable that takes + varargs. The last in_type will be the type of the all + varargs arguments. + func_name : str + Name of the function. This name must be globally unique. + function_doc : dict + A dictionary object with keys "summary" (str), + and "description" (str). + in_types : Dict[str, InputType] + Dictionary mapping function argument names to + their respective InputType specifications. + The argument names will be used to generate + documentation for the function. The number of + arguments specified here determines the function + arity. + out_type : DataType + Output type of the function. + + Examples + -------- + + >>> import pyarrow.compute as pc + >>> + >>> func_doc = {} + >>> func_doc["summary"] = "simple udf" + >>> func_doc["description"] = "add a constant to a scalar" + >>> + >>> def add_constant(ctx, array): + ... return pc.add(array, 1) + >>> + >>> func_name = "py_add_func" + >>> in_types = {"array": pc.InputType.array(pa.int64())} + >>> out_type = pa.int64() + >>> pc.register_scalar_function(add_constant, func_name, func_doc, + ... in_types, out_type) + >>> + >>> func = pc.get_function(func_name) + >>> func.name + 'py_add_func' + >>> answer = pc.call_function(func_name, [pa.array([20])]) + >>> answer + <pyarrow.lib.Int64Array object at 0x10c22e700> + [ + 21 + ] + """ + cdef: + c_string c_func_name + CArity c_arity + CFunctionDoc c_func_doc + CInputType in_tmp + vector[CInputType] c_in_types + PyObject* c_function + shared_ptr[CDataType] c_type + shared_ptr[COutputType] c_out_type + CStatus st + CScalarUdfOptions c_options + + c_func_name = tobytes(func_name) + + if callable(func): + c_function = <PyObject*>func + else: + raise TypeError("Object must be a callable") + + func_spec = inspect.getfullargspec(func) + num_args = -1 + if isinstance(in_types, dict): + for in_type in in_types.values(): + if isinstance(in_type, InputType): + in_tmp = (<InputType> in_type).input_type + c_in_types.push_back(in_tmp) + else: + raise TypeError("in_types must be of type InputType") + function_doc["arg_names"] = in_types.keys() + num_args = len(in_types) + else: + raise TypeError( + "in_types must be a dictionary of InputType") + + if func_spec.varargs: + c_arity = CArity(num_args, True) + else: + c_arity = CArity(num_args, False) Review Comment: ```suggestion c_arity = CArity(num_args, func_spec.varargs) ``` ########## python/pyarrow/_compute.pyx: ########## @@ -2275,3 +2362,214 @@ cdef CExpression _bind(Expression filter, Schema schema) except *: return GetResultValue(filter.unwrap().Bind( deref(pyarrow_unwrap_schema(schema).get()))) + + +cdef class ScalarUdfContext: + """ + Per-invocation function context/state. + + This object will always be the first argument to a user-defined + function. It should not be used outside of a call to the function. + """ + + def __init__(self): + raise TypeError("Do not call {}'s constructor directly" + .format(self.__class__.__name__)) + + cdef void init(self, const CScalarUdfContext &c_context): + self.c_context = c_context + + @property + def batch_length(self): + """ + The common length of all input arguments (int). + + In the case that all arguments are scalars, this value + is used to pass the "actual length" of the arguments, + e.g. because the scalar values are encoding a column + with a constant value. + """ + return self.c_context.batch_length + + @property + def memory_pool(self): + """ + A memory pool for allocations (:class:`MemoryPool`). + """ + return box_memory_pool(self.c_context.pool) + + +cdef inline CFunctionDoc _make_function_doc(dict func_doc) except *: + """ + Helper function to generate the FunctionDoc + This function accepts a dictionary and expect the + summary(str), description(str) and arg_names(List[str]) keys. + """ + cdef: + CFunctionDoc f_doc + vector[c_string] c_arg_names + + f_doc.summary = tobytes(func_doc["summary"]) + f_doc.description = tobytes(func_doc["description"]) + for arg_name in func_doc["arg_names"]: + c_arg_names.push_back(tobytes(arg_name)) + f_doc.arg_names = c_arg_names + # UDFOptions integration: + # TODO: https://issues.apache.org/jira/browse/ARROW-16041 + f_doc.options_class = tobytes("") + f_doc.options_required = False + return f_doc + + +cdef object box_scalar_udf_context(const CScalarUdfContext& c_context): + cdef ScalarUdfContext context = ScalarUdfContext.__new__(ScalarUdfContext) + context.init(c_context) + return context + + +cdef _scalar_udf_callback(user_function, const CScalarUdfContext& c_context, inputs): + """ + Helper callback function used to wrap the ScalarUdfContext from Python to C++ + execution. + """ + context = box_scalar_udf_context(c_context) + return user_function(context, *inputs) + + +def _get_scalar_udf_context(memory_pool, batch_length): + cdef CScalarUdfContext c_context + c_context.pool = maybe_unbox_memory_pool(memory_pool) + c_context.batch_length = batch_length + context = box_scalar_udf_context(c_context) + return context + + +def register_scalar_function(func, func_name, function_doc, in_types, + out_type): + """ + Register a user-defined scalar function. + + A scalar function is a function that executes elementwise + operations on arrays or scalars, and therefore whose results + generally do not depend on the order of the values in the + arguments. Accepts and returns arrays that are all of the + same size. These functions roughly correspond to the functions + used in SQL expressions. + + Parameters + ---------- + func : callable + A callable implementing the user-defined function. + It must take arguments equal to the number of + in_types defined. It must return an Array or Scalar + matching the out_type. It must return a Scalar if + all arguments are scalar, else it must return an Array. + + To define a varargs function, pass a callable that takes + varargs. The last in_type will be the type of the all + varargs arguments. + func_name : str + Name of the function. This name must be globally unique. + function_doc : dict + A dictionary object with keys "summary" (str), + and "description" (str). + in_types : Dict[str, InputType] + Dictionary mapping function argument names to + their respective InputType specifications. + The argument names will be used to generate + documentation for the function. The number of + arguments specified here determines the function + arity. + out_type : DataType + Output type of the function. + + Examples + -------- + + >>> import pyarrow.compute as pc + >>> + >>> func_doc = {} + >>> func_doc["summary"] = "simple udf" + >>> func_doc["description"] = "add a constant to a scalar" + >>> + >>> def add_constant(ctx, array): + ... return pc.add(array, 1) + >>> + >>> func_name = "py_add_func" + >>> in_types = {"array": pc.InputType.array(pa.int64())} + >>> out_type = pa.int64() + >>> pc.register_scalar_function(add_constant, func_name, func_doc, + ... in_types, out_type) + >>> + >>> func = pc.get_function(func_name) + >>> func.name + 'py_add_func' + >>> answer = pc.call_function(func_name, [pa.array([20])]) + >>> answer + <pyarrow.lib.Int64Array object at 0x10c22e700> + [ + 21 + ] + """ + cdef: + c_string c_func_name + CArity c_arity + CFunctionDoc c_func_doc + CInputType in_tmp + vector[CInputType] c_in_types + PyObject* c_function + shared_ptr[CDataType] c_type + shared_ptr[COutputType] c_out_type + CStatus st Review Comment: Where is this used? ########## python/pyarrow/_compute.pyx: ########## @@ -2251,3 +2338,219 @@ cdef CExpression _bind(Expression filter, Schema schema) except *: return GetResultValue(filter.unwrap().Bind( deref(pyarrow_unwrap_schema(schema).get()))) + + +cdef class ScalarUdfContext: + """A container to hold user-defined-function related + entities. `batch_length` and `MemoryPool` are important + entities in defining functions which require these details. + + Example + ------- + + ScalarUdfContext is used with the scalar user-defined-functions. + When defining such a function, the first parameter must be a + ScalarUdfContext object. This object can be used to hold important + information. This can be further enhanced depending on the use + cases of user-defined-functions. + + >>> def random(context, one, two): + return pc.add(one, two, memory_pool=context.memory_pool) + """ + + def __init__(self): + raise TypeError("Do not call {}'s constructor directly" + .format(self.__class__.__name__)) + + cdef void init(self, const CScalarUdfContext &c_context): + self.c_context = c_context + + @property + def batch_length(self): + """ + Returns the length of the batch associated with the + user-defined-function. Useful when the batch_length + is required to do computations specially when scalars + are parameters of the user-defined-function. + + Returns + ------- + batch_length : int + The number of batches used when calling + user-defined-function. + """ + return self.c_context.batch_length + + @property + def memory_pool(self): + """ + Returns the MemoryPool associated with the + user-defined-function. An already initialized + MemoryPool can be used within the + user-defined-function. + + Returns + ------- + memory_pool : MemoryPool + MemoryPool is obtained from the KernelContext + and passed to the ScalarUdfContext. + """ + return box_memory_pool(self.c_context.pool) + + +cdef inline CFunctionDoc _make_function_doc(dict func_doc) except *: + """ + Helper function to generate the FunctionDoc + This function accepts a dictionary and expect the + summary(str), description(str) and arg_names(List[str]) keys. + """ + cdef: + CFunctionDoc f_doc + vector[c_string] c_arg_names + + f_doc.summary = tobytes(func_doc["summary"]) + f_doc.description = tobytes(func_doc["description"]) + for arg_name in func_doc["arg_names"]: + c_arg_names.push_back(tobytes(arg_name)) + f_doc.arg_names = c_arg_names + # UDFOptions integration: + # TODO: https://issues.apache.org/jira/browse/ARROW-16041 + f_doc.options_class = tobytes("") + f_doc.options_required = False + return f_doc + +cdef _scalar_udf_callback(user_function, const CScalarUdfContext& c_context, inputs): + """ + Helper callback function used to wrap the ScalarUdfContext from Python to C++ + execution. + """ + cdef ScalarUdfContext context = ScalarUdfContext.__new__(ScalarUdfContext) + context.init(c_context) + return user_function(context, *inputs) + + +def register_scalar_function(func, func_name, function_doc, in_types, + out_type): + """ + Register a user-defined scalar function. + + A scalar function is a function that executes elementwise + operations on arrays or scalars, and therefore whose results + generally do not depend on the order of the values in the + arguments. Accepts and returns arrays that are all of the + same size. These functions roughly correspond to the functions + used in SQL expressions. Review Comment: Ping here. ########## python/pyarrow/tests/test_udf.py: ########## @@ -0,0 +1,458 @@ +# 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. + + +import pytest + +import pyarrow as pa +from pyarrow import compute as pc + + +unary_doc = {"summary": "add function", + "description": "test add function"} + + +def unary_function(ctx, scalar1): + return pc.call_function("add", [scalar1, 1]) + + +binary_doc = {"summary": "y=mx", + "description": "find y from y = mx"} + + +def binary_function(ctx, m, x): + return pc.call_function("multiply", [m, x]) + + +ternary_doc = {"summary": "y=mx+c", + "description": "find y from y = mx + c"} + + +def ternary_function(ctx, m, x, c): + mx = pc.call_function("multiply", [m, x]) + return pc.call_function("add", [mx, c]) + + +varargs_doc = {"summary": "z=ax+by+c", + "description": "find z from z = ax + by + c" + } + + +def varargs_function(ctx, *values): + base_val = values[:2] + res = pc.call_function("add", base_val) + for other_val in values[2:]: + res = pc.call_function("add", [res, other_val]) + return res + + +def check_scalar_function(name, + in_types, + out_type, + doc, + function, + input): + expected_output = function(None, *input) + pc.register_scalar_function(function, + name, doc, in_types, out_type) Review Comment: I think the fixture was only meant for the _registration_ aspect, not for the functions themselves. ########## python/pyarrow/_compute.pyx: ########## @@ -2275,3 +2362,214 @@ cdef CExpression _bind(Expression filter, Schema schema) except *: return GetResultValue(filter.unwrap().Bind( deref(pyarrow_unwrap_schema(schema).get()))) + + +cdef class ScalarUdfContext: + """ + Per-invocation function context/state. + + This object will always be the first argument to a user-defined + function. It should not be used outside of a call to the function. + """ + + def __init__(self): + raise TypeError("Do not call {}'s constructor directly" + .format(self.__class__.__name__)) + + cdef void init(self, const CScalarUdfContext &c_context): + self.c_context = c_context + + @property + def batch_length(self): + """ + The common length of all input arguments (int). + + In the case that all arguments are scalars, this value + is used to pass the "actual length" of the arguments, + e.g. because the scalar values are encoding a column + with a constant value. + """ + return self.c_context.batch_length + + @property + def memory_pool(self): + """ + A memory pool for allocations (:class:`MemoryPool`). + """ + return box_memory_pool(self.c_context.pool) + + +cdef inline CFunctionDoc _make_function_doc(dict func_doc) except *: + """ + Helper function to generate the FunctionDoc + This function accepts a dictionary and expect the + summary(str), description(str) and arg_names(List[str]) keys. + """ + cdef: + CFunctionDoc f_doc + vector[c_string] c_arg_names + + f_doc.summary = tobytes(func_doc["summary"]) + f_doc.description = tobytes(func_doc["description"]) + for arg_name in func_doc["arg_names"]: + c_arg_names.push_back(tobytes(arg_name)) + f_doc.arg_names = c_arg_names + # UDFOptions integration: + # TODO: https://issues.apache.org/jira/browse/ARROW-16041 + f_doc.options_class = tobytes("") + f_doc.options_required = False + return f_doc + + +cdef object box_scalar_udf_context(const CScalarUdfContext& c_context): + cdef ScalarUdfContext context = ScalarUdfContext.__new__(ScalarUdfContext) + context.init(c_context) + return context + + +cdef _scalar_udf_callback(user_function, const CScalarUdfContext& c_context, inputs): + """ + Helper callback function used to wrap the ScalarUdfContext from Python to C++ + execution. + """ + context = box_scalar_udf_context(c_context) + return user_function(context, *inputs) + + +def _get_scalar_udf_context(memory_pool, batch_length): + cdef CScalarUdfContext c_context + c_context.pool = maybe_unbox_memory_pool(memory_pool) + c_context.batch_length = batch_length + context = box_scalar_udf_context(c_context) + return context + + +def register_scalar_function(func, func_name, function_doc, in_types, + out_type): + """ + Register a user-defined scalar function. + + A scalar function is a function that executes elementwise + operations on arrays or scalars, and therefore whose results + generally do not depend on the order of the values in the + arguments. Accepts and returns arrays that are all of the + same size. These functions roughly correspond to the functions + used in SQL expressions. + + Parameters + ---------- + func : callable + A callable implementing the user-defined function. + It must take arguments equal to the number of + in_types defined. It must return an Array or Scalar + matching the out_type. It must return a Scalar if + all arguments are scalar, else it must return an Array. + + To define a varargs function, pass a callable that takes + varargs. The last in_type will be the type of the all + varargs arguments. + func_name : str + Name of the function. This name must be globally unique. + function_doc : dict + A dictionary object with keys "summary" (str), + and "description" (str). + in_types : Dict[str, InputType] + Dictionary mapping function argument names to + their respective InputType specifications. + The argument names will be used to generate + documentation for the function. The number of + arguments specified here determines the function + arity. + out_type : DataType + Output type of the function. + + Examples + -------- + + >>> import pyarrow.compute as pc + >>> + >>> func_doc = {} + >>> func_doc["summary"] = "simple udf" + >>> func_doc["description"] = "add a constant to a scalar" + >>> + >>> def add_constant(ctx, array): + ... return pc.add(array, 1) + >>> + >>> func_name = "py_add_func" + >>> in_types = {"array": pc.InputType.array(pa.int64())} + >>> out_type = pa.int64() + >>> pc.register_scalar_function(add_constant, func_name, func_doc, + ... in_types, out_type) + >>> + >>> func = pc.get_function(func_name) + >>> func.name + 'py_add_func' + >>> answer = pc.call_function(func_name, [pa.array([20])]) + >>> answer + <pyarrow.lib.Int64Array object at 0x10c22e700> + [ + 21 + ] + """ + cdef: + c_string c_func_name + CArity c_arity + CFunctionDoc c_func_doc + CInputType in_tmp + vector[CInputType] c_in_types + PyObject* c_function + shared_ptr[CDataType] c_type + shared_ptr[COutputType] c_out_type + CStatus st + CScalarUdfOptions c_options + + c_func_name = tobytes(func_name) + + if callable(func): + c_function = <PyObject*>func + else: + raise TypeError("Object must be a callable") Review Comment: ```suggestion raise TypeError("func must be a callable") ``` ########## python/pyarrow/_compute.pyx: ########## @@ -2251,3 +2338,219 @@ cdef CExpression _bind(Expression filter, Schema schema) except *: return GetResultValue(filter.unwrap().Bind( deref(pyarrow_unwrap_schema(schema).get()))) + + +cdef class ScalarUdfContext: + """A container to hold user-defined-function related + entities. `batch_length` and `MemoryPool` are important + entities in defining functions which require these details. + + Example + ------- + + ScalarUdfContext is used with the scalar user-defined-functions. + When defining such a function, the first parameter must be a + ScalarUdfContext object. This object can be used to hold important + information. This can be further enhanced depending on the use + cases of user-defined-functions. + + >>> def random(context, one, two): + return pc.add(one, two, memory_pool=context.memory_pool) + """ + + def __init__(self): + raise TypeError("Do not call {}'s constructor directly" + .format(self.__class__.__name__)) + + cdef void init(self, const CScalarUdfContext &c_context): + self.c_context = c_context + + @property + def batch_length(self): + """ + Returns the length of the batch associated with the + user-defined-function. Useful when the batch_length + is required to do computations specially when scalars + are parameters of the user-defined-function. + + Returns + ------- + batch_length : int + The number of batches used when calling + user-defined-function. + """ + return self.c_context.batch_length + + @property + def memory_pool(self): + """ + Returns the MemoryPool associated with the + user-defined-function. An already initialized + MemoryPool can be used within the + user-defined-function. + + Returns + ------- + memory_pool : MemoryPool + MemoryPool is obtained from the KernelContext + and passed to the ScalarUdfContext. + """ + return box_memory_pool(self.c_context.pool) + + +cdef inline CFunctionDoc _make_function_doc(dict func_doc) except *: + """ + Helper function to generate the FunctionDoc + This function accepts a dictionary and expect the + summary(str), description(str) and arg_names(List[str]) keys. + """ + cdef: + CFunctionDoc f_doc + vector[c_string] c_arg_names + + f_doc.summary = tobytes(func_doc["summary"]) + f_doc.description = tobytes(func_doc["description"]) + for arg_name in func_doc["arg_names"]: + c_arg_names.push_back(tobytes(arg_name)) + f_doc.arg_names = c_arg_names + # UDFOptions integration: + # TODO: https://issues.apache.org/jira/browse/ARROW-16041 + f_doc.options_class = tobytes("") + f_doc.options_required = False + return f_doc + +cdef _scalar_udf_callback(user_function, const CScalarUdfContext& c_context, inputs): + """ + Helper callback function used to wrap the ScalarUdfContext from Python to C++ + execution. + """ + cdef ScalarUdfContext context = ScalarUdfContext.__new__(ScalarUdfContext) + context.init(c_context) + return user_function(context, *inputs) + + +def register_scalar_function(func, func_name, function_doc, in_types, + out_type): + """ + Register a user-defined scalar function. + + A scalar function is a function that executes elementwise + operations on arrays or scalars, and therefore whose results + generally do not depend on the order of the values in the Review Comment: Ping? ########## python/pyarrow/compute.py: ########## @@ -76,6 +77,10 @@ get_function, list_functions, _group_by, + # Udf + register_scalar_function, + ScalarUdfContext, + _get_scalar_udf_context, Review Comment: And I think I've said this before, but it bears repeating: if you _do_ need a test-only helper, don't expose it in the public API like this. Tests can still import from `pyarrow._compute`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org