DuckDB.mojo: Mojo bindings for DuckDB

I finally got the bandwidth to continue working on my Mojo bindings for DuckDB, a fast analytical columnar database, so I’d like to add it here.

The project not completely new. I actually started working on it last summer, when the community showcases were still in discord as the forum didn’t exist yet. I also presented it at a community meeting about one year ago.

I took a break then, as I didn’t have the bandwidth and was stuck with an issue around passing structs by value into c , but kept watching Mojo mature and improve at an amazing speed.

Recently I started picking up the code again, and I’m making good progress towards a more usable package now:

  • Updated to Mojo 0.25.6
  • Found a workaround for the issue that had blocked me by adding a small c wrapper so I can pass the struct by pointer from Mojo.
  • Created a proper build using Pixi with the Mojo backend, as well as automatically building the c wrapper as a source dependency (this can probably be simplified).

I’ve now started to work on adding support for writing scalar DuckDB functions in Mojo, as I think it could be a very good fit, using it to write highly performant vectorized functions, leveraging SIMD or even GPUs.

7 Likes

I used these around 6 months ago! Awesome project, having access to duckdb as a swiss army knife for working with data is huge.

2 Likes

Amazing!! Thanks for sharing :slight_smile: We can highlight this in our next community blog!

1 Like