tidyverse / dtplyr

Data table backend for dplyr
https://dtplyr.tidyverse.org
Other
664 stars 58 forks source link

select(where(func)) does not work #435

Closed lindeloev closed 1 year ago

lindeloev commented 1 year ago

This works in dplyr:

iris |> 
    select(where(is.numeric))

It throws an error in dtplyr:

iris |> 
    dtplyr::lazy_dt() |>
    select(is.numeric) |>
    as_tibble()
Error in `select()`:
! This tidyselect interface doesn't support predicates.
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/tidyselect_error_predicates_unsupported>
Error in `select()`:
! This tidyselect interface doesn't support predicates.
---
Backtrace:
    ▆
 1. ├─tibble::as_tibble(select(dtplyr::lazy_dt(iris), is.numeric))
 2. ├─dplyr::select(dtplyr::lazy_dt(iris), is.numeric)
 3. └─dtplyr:::select.dtplyr_step(dtplyr::lazy_dt(iris), is.numeric)
Run rlang::last_trace(drop = FALSE) to see 13 hidden frames.

Adding select(where(is.numeric)) doesn't make a difference.

dtplyr 1.3.1; R 4.2.2; Windows 10 64-bit

mgirlich commented 1 year ago

Unfortunately, the error message is on purpose: it isn't supported. The reason is that we don't know the column types until we collect the data. But collecting the data is against the point of dbplyr.