Skip to content

Bug: as.Date() is not supported, even tho the docs say it is #815

@lwjohnst86

Description

@lwjohnst86

The documentation says that as.Date is supported, but when using "stingy" duckplyr tibble, it says "can't translate". The docs show an example, but they show it when in a duckdb_tibble(). This works fine but my guess is that .prudence is applied after creation of the tibble into a DuckDB object. Version of duckplyr is 1.1.3 (latest).

How can I convert a date from a string in DuckDB? I've tried as.POSITct() (as in the docs) and strptime() (which also has a DuckDB version), both don't work.

library(duckplyr)
#> Loading required package: dplyr
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
#> The duckplyr package is configured to fall back to dplyr when it encounters an
#> incompatibility. Fallback events can be collected and uploaded for analysis to
#> guide future development. By default, data will be collected but no data will
#> be uploaded.
#> ℹ Automatic fallback uploading is not controlled and therefore disabled, see
#>   `?duckplyr::fallback()`.
#> ✔ Number of reports ready for upload: 1.
#> → Review with `duckplyr::fallback_review()`, upload with
#>   `duckplyr::fallback_upload()`.
#> ℹ Configure automatic uploading with `duckplyr::fallback_config()`.
#> ✔ Overwriting dplyr methods with duckplyr methods.
#> ℹ Turn off with `duckplyr::methods_restore()`.

duckdb_tibble(
  date_str = "2024-01-01",
  date = as.Date(date_str),
  .prudence = "stingy"
)
#> # A duckplyr data frame: 2 variables
#>   date_str   date      
#>   <chr>      <date>    
#> 1 2024-01-01 2024-01-01

duckdb_tibble(
  date_str = "2024-01-01",
  .prudence = "stingy"
) |>
  mutate(
    date = as.Date(date_str)
  )
#> Error in `mutate()`:
#> ! This operation cannot be carried out by DuckDB, and the input is a
#>   stingy duckplyr frame.
#> ℹ Use `compute(prudence = "lavish")` to materialize to temporary storage and
#>   continue with duckplyr.
#> ℹ See `vignette("prudence")` for other options.
#> Caused by error in `mutate()`:
#> ! Can't translate function `as.Date()`.

Created on 2025-11-24 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions