-
Notifications
You must be signed in to change notification settings - Fork 179
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
Can't use [[ with scoped mutate #306
Comments
[[
appears sensitive to map column name[[
and mutate_at()
There's a lot going on in your reprex, but it seems like all of the problems have the same error, so I think it makes sense to fix that first: library(dbplyr)
library(dplyr, warn.conflicts = FALSE)
lf <- lazy_frame(x = list(c(a = 1, b = 2), c(a = 3, b = 4)))
lf %>% mutate_at(vars(x), list(a = ~`[[`(., "a"), b = ~`[[`(., "b")))
#> <SQL>
#> Error in x[[]]: argument "i" is missing, with no default Created on 2019-05-30 by the reprex package (v0.2.1.9000) I see a different error message to you, but the most likely explanation is that I have some development version of something installed at the moment. |
Simpler reprex with slightly different error: library(dbplyr)
library(dplyr, warn.conflicts = FALSE)
lf <- lazy_frame(x = list(c(a = 1, b = 2), c(a = 3, b = 4)))
lf %>% mutate_all(list(a = ~ .$a, b = ~ .$b))
#> <SQL>
#> Error in eval_bare(x, .env): argument "y" is missing, with no default Created on 2019-05-30 by the reprex package (v0.2.1.9000) |
[[
and mutate_at()
Installed cran dplyr and now I'm getting the same error as above. |
As a follow-up, I've discovered that using the names of other functions for the list column "avoids" the error, though the output does not appear correct, either. It just so happened that I noticed the library(dbplyr)
library(dplyr, warn.conflicts = FALSE)
lf0 <- lazy_frame(x = list(c(a = 1, b = 2), c(a = 3, b = 4)))
lf0 %>% mutate_all(list(a = ~ .$a, b = ~ .$b))
#> Error in as.pairlist(list(...)): object 'x' not found
lf1 <- lazy_frame(match = list(c(a = 1, b = 2), c(a = 3, b = 4)))
lf1 %>% mutate_all(list(a = ~ .$a, b = ~ .$b))
#> <SQL>
#> SELECT `match`, `.`.`a` AS `a`, `.`.`b` AS `b`
#> FROM `df`
lf2 <- lazy_frame(filter = list(c(a = 1, b = 2), c(a = 3, b = 4)))
lf2 %>% mutate_all(list(a = ~ .$a, b = ~ .$b))
#> <SQL>
#> SELECT `filter`, `.`.`a` AS `a`, `.`.`b` AS `b`
#> FROM `df` Created on 2019-06-04 by the reprex package (v0.3.0) |
I want to dynamically extract one or more keys from a map column using the new remote evaluation of
[[
. I would expect each of the cases in the reprex below to give equivalent output.x
mutate()
x
mutate_at()
x
mutate()
x
mutate_at()
x
extract_keys()
dim
extract_keys()
My best guess is that there is some interaction among
[[
,mutate_at()
, and quasiquotation. The target DB is Presto, but this issue doesn't appear specific to Presto. Also, I suspect this is related to other recent issues, e.g., #305.Created on 2019-05-20 by the reprex package (v0.3.0)
Session info
The text was updated successfully, but these errors were encountered: