-
Notifications
You must be signed in to change notification settings - Fork 175
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
distinct(.keep_all = TRUE) does not work with filtering joins #1534
Comments
Here's another variation on the above reprex that's also a little smaller (by eliminating some of the extra calls that library(dplyr, warn.conflicts = FALSE)
library(dbplyr, warn.conflicts = FALSE)
df1 <- dbplyr::lazy_frame(id = 1)
df2 <- dbplyr::lazy_frame(id = 1)
df2 |>
filter(row_number() == 1L) |>
anti_join(df1, y = _)
#> Joining with `by = join_by(id)`
#> Error in `get_env()`:
#> ! Can't extract an environment from a call. Here's the generated SQL for the filtered df2 |>
filter(row_number() == 1L)
#> <SQL>
#> SELECT `id`
#> FROM (
#> SELECT `df`.*, ROW_NUMBER() OVER () AS `col01`
#> FROM `df`
#> ) AS `q01`
#> WHERE (`col01` = 1)
Lines 266 to 273 in 1ff6363
# debugging inside sql_build.lazy_semi_join_query()
str(where)
#> List of 1
#> $ : language sql("`RHS`")$col01 == 1L Prior to this commit, the where clause would be # debugging inside sql_build.lazy_semi_join_query()
str(where)
#> List of 1
#> $ : language RHS$col01 == 1L which doesn't contain any function calls and therefore doesn't hit the code paths in Lines 164 to 166 in 1ff6363
If you mark unknown <- setdiff(all_calls(expr), c(names(variant), "sql")) you get past this error but still run into Lines 192 to 199 in 1ff6363
I'm not sure what the best fix would be but here are two options I've thought of:
If the first option sounds reasonable, I'd be happy to submit a PR. (The second option would probably be more easily handled by someone with more experience with dbplyr internals.) |
An error is produced when trying to use
distinct(..., .keep_all = TRUE)
within the second argument of a filtering join. The error does not occur when used within the first argument of a filtering join, within either argument of a mutating join, or when using.keep_all = FALSE
.The text was updated successfully, but these errors were encountered: