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

transmute does not work with DBI #3370

Closed
danielmcauley opened this issue Feb 22, 2018 · 12 comments
Closed

transmute does not work with DBI #3370

danielmcauley opened this issue Feb 22, 2018 · 12 comments
Labels
reprex needs a minimal reproducible example

Comments

@danielmcauley
Copy link

transmute() exhibits desired behavior with data frames but throws an error when used in the context of a DBI.

# this runs

library(dplyr)

transmute(mtcars, blah = cyl)
# this does not

library(dbplyr)

con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
copy_to(con, mtcars)
mtcars2 <- tbl(con, "mtcars")
transmute(mtcars2, blah = cyl)

# Error: Variable context not set
@edgararuiz-zz
Copy link

Hi, I just tried that out and it worked in my computer:

suppressPackageStartupMessages({                    
library(dplyr)                                      
library(dbplyr)                                     
})                                                  
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
copy_to(con, mtcars)                                
mtcars2 <- tbl(con, "mtcars")                       
transmute(mtcars2, blah = cyl)                      
#> # Source:   lazy query [?? x 1]
#> # Database: sqlite 3.19.3 [:memory:]
#>     blah
#>    <dbl>
#>  1  6.00
#>  2  6.00
#>  3  4.00
#>  4  6.00
#>  5  8.00
#>  6  6.00
#>  7  8.00
#>  8  4.00
#>  9  4.00
#> 10  6.00
#> # ... with more rows
DBI::dbDisconnect(con)                              

Maybe you may need to upgrade your packages?

@danielmcauley
Copy link
Author

Thanks, @edgararuiz. I'm on dplyr 0.7.4 and dbplyr 1.2.1 so I don't think those should be the issue. Here's my session info in case there's something I'm missing.

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.13.3

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dbplyr_1.2.1  dplyr_0.7.4

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.15     digest_0.6.9     assertthat_0.2.1 R6_2.2.2        
 [5] DBI_0.7          magrittr_1.5     RSQLite_2.0      pillar_1.1.0    
 [9] rlang_0.1.6      blob_1.1.0       bindrcpp_0.2     tools_3.4.0     
[13] bit64_0.9-7      glue_1.2.0       purrr_0.2.4      bit_1.1-12      
[17] yaml_2.1.13      compiler_3.4.0   pkgconfig_2.0.1  memoise_1.0.0   
[21] tidyselect_0.2.3 bindr_0.1        tibble_1.4.2

@krlmlr
Copy link
Member

krlmlr commented Feb 28, 2018

Can you please try updating tidyselect ?

@lionel-
Copy link
Member

lionel- commented Feb 28, 2018

dbplyr now uses tidyselect and it looks like tidyselect doesn't hotpatch dplyr for some reason. This problem should go away once the next version of dplyr comes out.

@krlmlr
Copy link
Member

krlmlr commented Feb 28, 2018

Thanks. I don't understand "hotpatch".

@lionel-
Copy link
Member

lionel- commented Feb 28, 2018

This ugly thing here :) https://github.com/tidyverse/tidyselect/blob/master/R/tidyselect.R#L9

Necessary because tidyr uses tidyselect but not dplyr (and now dbplyr uses it as well).

@krlmlr
Copy link
Member

krlmlr commented Feb 28, 2018

I still don't understand, tidyr does import dplyr even in v0.8.0.

@lionel-
Copy link
Member

lionel- commented Feb 28, 2018

yes but since tidyr uses tidyselect the variable context from the select helpers (which are exported from dplyr) must be the one from tidyselect.

@danielmcauley
Copy link
Author

danielmcauley commented Mar 1, 2018

@krlmlr I updated tidyselect as you suggested but I am still getting the same error. These are the versions I'm currently running: tidyselect_0.2.4 dbplyr_1.2.1 dplyr_0.7.4

@krlmlr krlmlr added the reprex needs a minimal reproducible example label Mar 1, 2018
@krlmlr
Copy link
Member

krlmlr commented Mar 1, 2018

@lionel-: Do you think reinstalling dplyr can help?

@lionel-
Copy link
Member

lionel- commented Mar 1, 2018

I don't know what's going on. If you install the dev version it should work though.

@lock
Copy link

lock bot commented Nov 16, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Nov 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
reprex needs a minimal reproducible example
Projects
None yet
Development

No branches or pull requests

6 participants