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

Adding function translations for the session #158

Open
brichards920 opened this issue May 6, 2024 · 2 comments
Open

Adding function translations for the session #158

brichards920 opened this issue May 6, 2024 · 2 comments

Comments

@brichards920
Copy link

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.

@krlmlr
Copy link
Collaborator

krlmlr commented May 7, 2024

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.

@krlmlr
Copy link
Collaborator

krlmlr commented May 7, 2024

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

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

2 participants