duckdblabs/duckplyr

Adding function translations for the session

Opened this issue · 4 comments

Using dplyr and dbplyr, it's possible to work around missing function translations by calling duckdb functions directly, or by writing macros that can do the translation.

Here's how I might quickly do something like that.

require(dplyr)
require(duckdb)

con <- dbConnect(duckdb())

dbSendStatement(con, 'create or replace macro TIMESTWO (x) as x::NUMERIC*2.0;')

out <- copy_to(con, iris, overwrite = T) %>%
  mutate(y = TIMESTWO(Sepal.Length)) %>%
  collect()

I run into fallback situations pretty quickly with duckplyr, and it would be nice to be able to write macros or adjust my code to work around them. If possible, could you please share an example of how I might do something like the above in duckplyr for my R session? I've been attempting to do this with relexpr_set_alias and to_duckdb_expr, but I haven't been making much progress.

Thanks, interesting idea.

The translations currently aren't very well organized (a lot happens in R/relational.R). Let me think about how to open this for extension.

Until then, would you like to share examples of fallback situations that would help you most (perhaps one issue per example)?

Because we will never be able to translate everything, a way to provide custom translations can help bridge the gap in some cases.

For now, clone the repository and follow the contributing guide.