Last active
January 28, 2018 19:44
-
-
Save infotroph/19513e684c97b576e24c8b1058b082ee to your computer and use it in GitHub Desktop.
Why not .data in sql filter?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
# local df works as expected with or without .data | |
mtcars %>% select(mpg) %>% filter(mpg > 33) | |
# mpg | |
# 1 33.9 | |
mtcars %>% select(.data$mpg) %>% filter(.data$mpg > 33) | |
# mpg | |
# 1 33.9 | |
con = DBI::dbConnect(RSQLite::SQLite(), path = ":memory:") | |
copy_to(con, mtcars, "carsql", temporary=F) | |
# sql works as expected without .data | |
tbl(con, "carsql") %>% select(mpg) %>% filter(mpg > 33) | |
# # Source: lazy query [?? x 1] | |
# # Database: sqlite 3.19.3 [] | |
# mpg | |
# <dbl> | |
# 1 33.9 | |
# sql select works as expected with .data | |
tbl(con, "carsql") %>% select(.data$mpg) %>% filter(mpg > 33) | |
# # Source: lazy query [?? x 1] | |
# # Database: sqlite 3.19.3 [] | |
# mpg | |
# <dbl> | |
# 1 33.9 | |
# sql filter does not work with .data | |
tbl(con, "carsql") %>% select(.data$mpg) %>% filter(.data$mpg > 33) | |
# Error in eval_bare(call, env) : object '.data' not found | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Behavior doesn't change when I switch to dev versions of Tidyverse packages.
Created on 2018-01-28 by the reprex package (v0.1.1.9000).