vibhatha commented on a change in pull request #12590:
URL: https://github.com/apache/arrow/pull/12590#discussion_r839515132



##########
File path: python/pyarrow/_compute.pyx
##########
@@ -199,6 +202,135 @@ FunctionDoc = namedtuple(
      "options_required"))
 
 
+cdef wrap_arity(const CArity c_arity):
+    """
+    Wrap a C++ Arity in an Arity object
+    """
+    cdef Arity arity = Arity.__new__(Arity)
+    arity.init(c_arity)
+    return arity
+
+
+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 interface for defining input-types for streaming execution engine
+    applications. 
+    """
+
+    def __init__(self):
+        raise TypeError("Cannot use constructor to initialize InputType")
+
+    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
+
+        Parameter
+        ---------
+        data_type: DataType
+
+        Examples
+        --------
+
+        >>> import pyarrow as pa
+        >>> from pyarrow.compute import InputType
+        >>> in_type = InputType.scalar(pa.int32())
+        <pyarrow._compute.InputType object at 0x1029fdcb0>
+        """
+        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
+
+        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>
+        """
+        cdef:
+            shared_ptr[CDataType] c_data_type
+            CInputType c_input_type
+        c_data_type = pyarrow_unwrap_data_type(data_type)
+        c_input_type = CInputType.Array(c_data_type)
+        return wrap_input_type(c_input_type)
+
+
+cdef class Arity(_Weakrefable):

Review comment:
       I am not sure if I understood the suggestion correctly. The current code 
outputs the following,
   
   ```python
   pc.get_function("py_add_one_func")
   ```
   
   ```bash
   arrow.compute.Function<name=py_add_one_func, kind=scalar, arity=1, 
num_kernels=1>
   ```
   
   I also understand we can just use the interface defined in the 
`libarrow.pxd` directly without using this class. 
   Is it what is intended in this suggestion? 




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to