There’s no real need for this but the only remaining friction is that it’s hard to use Julia UDFs with DuckDB. If Julia was built in Julia then it might be easier to use Julia with it. However not sure if this is still the case if a Julia DuckDB was compiled into a binary and can become embedded in which case you would need to compile your Julia UDFs anyway.
1 Like
SQLite.jl has a really nice interface for working with UDFs. I wonder if theres a way to leverage what theyve done there.
I know there is one person working on a really convenient macro for UDFs in duckdb in this discussion
using DuckDB
import DuckDB: execute, @create_scalar_function, register_scalar_function
db = DuckDB.DB(":memory:")
my_sum = (a,b) -> a+b
# use of a macro to generate specialized wrapper code
fun = @create_scalar_function "my_sum" [Int64, Int64] Int64 my_sum
register_scalar_function(db, fun)
execute(db, "SELECT my_sum(1,2)")
# way to remove this as well
unregister_scalar_function(db, "my_sum")
2 Likes