pitrou commented on PR #14320:
URL: https://github.com/apache/arrow/pull/14320#issuecomment-1372473478

   One other possibility would be to first create the function and then 
register kernels one by one:
   ```python
   udf = pc.register_scalar_function(
       name="y=x*2",
       arg_names=["x"],
       doc = {"summary": "multiply by two function",
              "description": "test multiply function"}
       )
   for in_type in [pa.int64(), pa.float64()]:
       udf.add_kernel([in_type], in_type, impl)
   ```
   
   It could also open the way to a decorator-like syntax:
   ```python
   
   udf = pc.register_scalar_function(
       name="y=x*2",
       arg_names=["x"],
       doc = {"summary": "multiply by two function",
              "description": "test multiply function"}
       )
   
   @udf.kernel([pa.float64()], pa.float64())
   @udf.kernel([pa.int64()], pa.int64())
   def impl(ctx, x):
       # ...
   ```
   
   @jorisvandenbossche Opinions on which kind of API would be desirable here?


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