You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "westonpace (via GitHub)" <gi...@apache.org> on 2023/01/26 13:29:18 UTC
[GitHub] [arrow] westonpace commented on issue #33883: [Python] Adopt a more pythonic method for UDF registration
westonpace commented on issue #33883:
URL: https://github.com/apache/arrow/issues/33883#issuecomment-1405009345
I think [this suggestion](https://github.com/apache/arrow/pull/14320#issuecomment-1372473478), from @pitrou , is rather compelling:
```
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)
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):
# ...
```
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org