vibhatha commented on code in PR #12590: URL: https://github.com/apache/arrow/pull/12590#discussion_r851843799
########## python/pyarrow/_compute.pyx: ########## @@ -199,6 +203,87 @@ FunctionDoc = namedtuple( "options_required")) +cdef wrap_input_type(const CInputType c_input_type): + """ + Wrap a C++ InputType in an InputType object. + """ + cdef InputType input_type = InputType.__new__(InputType) + input_type.init(c_input_type) + return input_type + + +cdef class InputType(_Weakrefable): + """ + An input type specification for a user-defined function. + """ + + def __init__(self): + raise TypeError("Do not call {}'s constructor directly" + .format(self.__class__.__name__)) + + cdef void init(self, const CInputType &input_type): + self.input_type = input_type + + @staticmethod + def scalar(data_type): + """ + Create a scalar input type of the given data type. + + Arguments to a UDF have both a data type and a shape, + either array or scalar. A scalar InputType means that + this argument must be passed a Scalar. + + Parameter + --------- + data_type: DataType + + Examples + -------- + + >>> import pyarrow as pa + >>> from pyarrow.compute import InputType + >>> in_type = InputType.scalar(pa.int32()) + scalar[int32] + """ + cdef: + shared_ptr[CDataType] c_data_type + CInputType c_input_type + c_data_type = pyarrow_unwrap_data_type(data_type) + c_input_type = CInputType.Scalar(c_data_type) + return wrap_input_type(c_input_type) + + @staticmethod + def array(data_type): + """ + Create an array input type of the given data type. + + Arguments to a UDF have both a data type and a shape, + either array or scalar. An array InputType means that + this argument must be passed an Array. + + Parameter + --------- + data_type: DataType + + Examples + -------- + + >>> import pyarrow as pa + >>> from pyarrow.compute import InputType + >>> in_type = InputType.array(pa.int32()) + <pyarrow._compute.InputType object at 0x102ba4850> Review Comment: typo. -- 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