# Is it hard to support Julia UDFs in DuckDB?

**URL:** https://discourse.julialang.org/t/is-it-hard-to-support-julia-udfs-in-duckdb/118509
**Category:** Data
**Created:** [August 23, 2024, 12:11am UTC](https://discourse.julialang.org/t/is-it-hard-to-support-julia-udfs-in-duckdb/118509 "2024-08-23T00:11:59Z")
**Posts on this page:** 1
**Showing post:** 24

<div class="post-metadata">

### Author: ![tqml](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tqml/32/22710_2.png) [@tqml](https://discourse.julialang.org/u/tqml)
#### Post date: [December 20, 2024, 2:08pm UTC](https://discourse.julialang.org/t/is-it-hard-to-support-julia-udfs-in-duckdb/118509/24 "2024-12-20T14:08:08Z")

</div>

Another update from my side 😃

I opened a [pull request](https://github.com/duckdb/duckdb/pull/15430) at the DuckDB repo that implements UDF like it was suggested in the Github Discussion.

Implementing the creation of the function pointer for C was more difficult than I thought, so there might be a better way to do this. If I have any suggestions, improvement ideas, I’m happy for any “pointers” 🙂

Usage will look like this:

```julia
using DuckDB, DataFrames

f_add = (a, b) -> a + b
db = DuckDB.DB()
con = DuckDB.connect(db)

# Create the scalar function 
# the second argument can be omitted if the function name is identical to a global symbol
fun = DuckDB.@create_scalar_function f_add(a::Int, b::Int)::Int f_add
DuckDB.register_scalar_function(con, fun)

df = DataFrame(a = [1, 2, 3], b = [1, 2, 3])
DuckDB.register_table(con, df, "test1")

result = DuckDB.execute(con, "SELECT f_add(a, b) as result FROM test1") |> DataFrame

```

Feedback of course welcome 🙂

---

_[View the full topic](https://discourse.julialang.org/t/is-it-hard-to-support-julia-udfs-in-duckdb/118509)._
