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



##########
File path: python/pyarrow/_compute.pyx
##########
@@ -2179,3 +2314,205 @@ cdef CExpression _bind(Expression filter, Schema 
schema) except *:
 
     return GetResultValue(filter.unwrap().Bind(
         deref(pyarrow_unwrap_schema(schema).get())))
+
+
+cdef CFunctionDoc _make_function_doc(func_doc):
+    """
+    Helper function to generate the FunctionDoc
+    """
+    cdef:
+        CFunctionDoc f_doc
+        vector[c_string] c_arg_names
+        c_bool c_options_required
+    if isinstance(func_doc, dict):
+        if func_doc["summary"] and isinstance(func_doc["summary"], str):
+            f_doc.summary = func_doc["summary"].encode()
+        else:
+            raise ValueError("key `summary` cannot be None")
+
+        if func_doc["description"] and isinstance(func_doc["description"], 
str):
+            f_doc.description = func_doc["description"].encode()
+        else:
+            raise ValueError("key `description` cannot be None")
+
+        if func_doc["arg_names"] and isinstance(func_doc["arg_names"], list):
+            for arg_name in func_doc["arg_names"]:
+                if isinstance(arg_name, str):
+                    c_arg_names.push_back(arg_name.encode())
+                else:
+                    raise ValueError(
+                        "key `arg_names` must be a list of strings")
+            f_doc.arg_names = c_arg_names
+        else:
+            raise ValueError("key `arg_names` cannot be None")
+
+        if func_doc["options_class"] and isinstance(func_doc["options_class"], 
str):
+            f_doc.options_class = func_doc["options_class"].encode()
+        else:
+            raise ValueError("key `options_class` cannot be None")
+
+        if isinstance(func_doc["options_required"], bool):
+            c_options_required = func_doc["options_required"]
+            f_doc.options_required = c_options_required
+        else:
+            raise ValueError("key `options_required` must be bool")
+
+        return f_doc
+    else:
+        raise TypeError(f"func_doc must be a dictionary")
+
+
+cdef class UDFError(Exception):
+    cdef dict __dict__
+
+    def __init__(self, message='', extra_info=b''):
+        super().__init__(message)
+        self.extra_info = tobytes(extra_info)
+
+    cdef CStatus to_status(self):
+        message = tobytes("UDF error: {}".format(str(self)))
+        return CStatus_UnknownError(message)
+
+
+cdef class UDFRegistrationError(UDFError):
+
+    def __init__(self, message='', extra_info=b''):
+        super().__init__(message, extra_info)
+
+    cdef CStatus to_status(self):
+        message = tobytes("UDF Registration error: {}".format(str(self)))
+        return CStatus_UnknownError(message)
+
+
+def register_function(func_name, arity, function_doc, in_types,
+                      out_type, callback, mem_allocation="no_preallocate",
+                      null_handling="computed_no_preallocate"):
+    """
+    Register a user-defined-function (function) 
+
+    Parameters
+    ----------
+
+    func_name: str
+        function name 

Review comment:
       That's a good question. Then we need to somehow create a unique 
signature for that before we call the C++ interface. 
   I see your point and it is very usable if we can provide that. So the arity, 
in_types can be used to generate that unique function name. Is this is a 
correct understanding?




-- 
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


Reply via email to