Replies: 2 comments
-
Here is an example: #!/usr/bin/env python
from chdb.udf import chdb_udf
from chdb import query
@chdb_udf()
def sum_udf(lhs, rhs):
return int(lhs) + int(rhs)
print(query("select sum_udf(12,22)")) |
Beta Was this translation helpful? Give feedback.
0 replies
-
thanks, but python udf is a bit slow. >>> import time
>>> t=time.time();print(query("select sum(cast (sum_udf(i,j) as int)) from(select number i,number*3 j from numbers(1000000))"));print(time.time()-t)
1999998000000
2.1727423667907715
>>> t=time.time();print(query("select sum(cast (i+j as int)) from(select number i,number*3 j from numbers(1000000))"));print(time.time()-t)
1999998000000
0.03494834899902344 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I saw https://ucasfl.github.io/2020/12/25/How-to-Implement-User-defined-functions-in-ClickHouse/
it needs add new files of the udf and modify the source code of clickhouse,
https://datafusion.apache.org/library-user-guide/functions/adding-udfs.html seems easier, it only need add new files.
what is the easy way for chdb?
Beta Was this translation helpful? Give feedback.
All reactions