# 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:** 41

<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:** [February 3, 2025, 4:52pm UTC](https://discourse.julialang.org/t/is-it-hard-to-support-julia-udfs-in-duckdb/118509/41 "2025-02-03T16:52:31Z")

</div>

Hmm, strange…  
Using the example from @asbisen is the `duckdata.db.wal` file getting created after the function is called but the moment the garbage collector starts it disappears (and the error opening the database is gone.)  
I was hoping the Stmt() handle created by `execute()` is the only thing that keeps the connection open but maybe there are more…

After a bit research I found some discussions that using finalizers for resource cleanup has some isseus ([1](https://discourse.julialang.org/t/current-best-practices-for-resource-acquizition-and-cleanup/35509), [2](https://discourse.julialang.org/t/eager-finalization-and-smart-pointers/92462/5), [3](https://github.com/JuliaLang/julia/issues/11207) ) mostly because of garbage collection intervals.  
And yeah, the current DuckDB julia package uses finalizers for cleanup.

Julia seems to lack a good way to have destructors that are based on the scope of variable (or at least that I’m aware of)

---

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