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



##########
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 
+    arity: Arity
+        arity of the function
+    function_doc: dict
+        a dictionary object with keys 
+        ("summary", 
+        "description", 
+        "arg_names", 
+        "options_class", (not supported yet)
+        "options_required" (not supported yet)

Review comment:
       I understand, that's better. 




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