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

Explicit namespacing for translated functions #512

Open
TimTaylor opened this issue Jan 28, 2025 · 1 comment
Open

Explicit namespacing for translated functions #512

TimTaylor opened this issue Jan 28, 2025 · 1 comment
Milestone

Comments

@TimTaylor
Copy link
Contributor

In version v0.3.2 functions such as wday() seemed to work without needing lubridate loaded or explicit namespacing (i.e. lubridate::wday()). This no longer seems to be the case. Is this deliberate?

I've noticed this difference with both the main branch (0.99.99.9923) and the 0.4.1 release.

@krlmlr
Copy link
Member

krlmlr commented Jan 29, 2025

Thanks. This is by design, it works with library(lubridate) .

We need to make the error a bit nicer, though.

options(conflicts.policy = list(warn = FALSE))
library(dplyr)

# Bad:
duckplyr::duckdb_tibble(date = Sys.Date() + 1:5, .funnel = TRUE) |>
  mutate(dow = wday(date))
#> Error in `mutate()`:
#> ! This operation cannot be carried out by DuckDB, and the input is a
#>   funneled duckplyr frame.
#> ℹ Use `compute(funnel = FALSE)` to materialize to temporary storage and
#>   continue with duckplyr.
#> ℹ See `vignette("funnel")` for other options.
#> Caused by error in `rel_find_call()` at duckplyr/R/translate.R:162:3:
#> ! Function `wday` does not map to `lubridate::wday`.

# Good:
duckplyr::duckdb_tibble(date = Sys.Date() + 1:5, .funnel = TRUE) |>
  mutate(dow = lubridate::wday(date))
#> # A duckplyr data frame: 2 variables
#>   date         dow
#>   <date>     <int>
#> 1 2025-01-30     5
#> 2 2025-01-31     6
#> 3 2025-02-01     7
#> 4 2025-02-02     1
#> 5 2025-02-03     2

# Also good:
library(lubridate)
duckplyr::duckdb_tibble(date = Sys.Date() + 1:5, .funnel = TRUE) |>
  mutate(dow = wday(date))
#> # A duckplyr data frame: 2 variables
#>   date         dow
#>   <date>     <int>
#> 1 2025-01-30     5
#> 2 2025-01-31     6
#> 3 2025-02-01     7
#> 4 2025-02-02     1
#> 5 2025-02-03     2

Created on 2025-01-29 with reprex v2.1.1

@krlmlr krlmlr added this to the 1.0.0 milestone Jan 29, 2025
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