Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Defined Functions with R #181

Open
ran-codes opened this issue Jun 7, 2024 · 4 comments
Open

User Defined Functions with R #181

ran-codes opened this issue Jun 7, 2024 · 4 comments

Comments

@ran-codes
Copy link

duckdb/duckdb#12438 (comment)

suggested to ask this in this repo.

Our team uses the tidyverse API and some basics statistics function in R for much of our data work. We have shifted to Duckdb - particualrly the duckdb-dbt workflow - and would be a gamechanger if we could do some of our R work in duckdb via UDF.

I have read duckdb/duckdb#471 but am wonder if there is plans for support for other language UDFs. I think it would be a game changing feature.

@paleolimbot
Copy link

A while back I was involved in implementing Arrow UDFs and the challenge was basically that R code must execute on the same thread, so there is a slightly awkward dance where whenever Arrow does something that might execute some R code (like a user-defined function), we have to launch a thread to do "do arrow stuff" and run an event loop on the R thread that waits for R tasks that need executing on the other thread.

Some (not so) light reading that might be relevant (I am not sure how similar DuckDB UDFs are to Arrow UDFs):

https://github.com/apache/arrow/blob/fd11b7a042f0a020a0cde34e043ad2e77752bca6/r/src/safe-call-into-r.h

https://github.com/apache/arrow/blob/fd11b7a042f0a020a0cde34e043ad2e77752bca6/r/src/compute.cpp#L633-L788

@alejandrohagan
Copy link

I'm just here to lend my support.

I'm building shiny apps with duckdb back ends and it would be so fantastic if we could get R UDFs.

@ran-codes
Copy link
Author

coming back to this. Yes I think happy to contribute as well.

@paleolimbot do you have any PR for other duckdb features similiar to this that potentially itnerested contributors can get a glimpse at just to try to understand at a high level the work that would have to happen for this?

@krlmlr
Copy link
Collaborator

krlmlr commented Aug 16, 2024

I don't think anything like what Dewey described in #181 (comment) currently exists in the duckdb R package. This would be a new development, exciting for sure, but also somewhat difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants