Created
March 18, 2019 02:20
-
-
Save colearendt/fe74f93afed597ad5d3504c2ef4c1a12 to your computer and use it in GitHub Desktop.
Exploring dbplyr
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
# create database connection | |
con <- dbConnect(...) | |
# define tbl object | |
mytbl <- tbl(con, "table") | |
# dbplyr:::tbl_sql | |
# -> op_base_remote | |
# --> get list of var names (by doing a quick query) | |
# --> op_base | |
# ----> STORES vars, "op_base_remote" tag | |
# dplyr::make_tbl | |
mytbl1 <- mytbl %>% filter(column > 2) | |
# dbplyr:::filter.tbl_lazy | |
# -> quos(...) | |
# -> partial_eval_dots(dots, vars = op_vars(.data)) | |
# -> add_op_single("filter", .data, dots = dots) | |
mytbl2 <- mytbl1 %>% mutate(column2 = "a") | |
# dbplyr:::mutate.tbl_lazy | |
# -> dots <- quos(..., .named = TRUE) | |
# -> dots <- partial_eval_dots(dots, vars = op_vars(.data)) | |
# -> nest_vars(.data, dots, union(op_vars(.data), op_grps(.data))) | |
mytbl2 | |
# dbplyr:::print.tbl_sql | |
# -> cat_line(format(...)) | |
# --> tibble:::format.tbl | |
# --> tibble:::trunc_mat | |
# ---> as.data.frame(head(x, n)) | |
# ---> dbplyr:::head.tbl_lazy | |
# ----> op_single("head", x = x$ops, args = list(n = n)) | |
# ---> dbplyr:::as.data.frame.tbl_sql | |
# ----> as.data.frame(collect(x, n = n)) | |
# ----> dbplyr:::collect.tbl_sql | |
# -----> dbplyr:::db_sql_render | |
# -----> dbplyr:::db_collect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment