Created
April 15, 2017 05:26
-
-
Save yutannihilation/bec59b8b842fa3bbedbe76918ddfc4cb to your computer and use it in GitHub Desktop.
This file contains hidden or 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(dplyr) | |
| con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:") | |
| DBI::dbWriteTable(con, "mtcars", mtcars) | |
| mtcars2 <- tbl(con, "mtcars") | |
| mtcars2 | |
| mtcars2 %>% | |
| select(cyl) %>% | |
| head(3) %>% | |
| show_query() | |
| #> <SQL> | |
| #> SELECT `cyl` AS `cyl` | |
| #> FROM `mtcars` | |
| #> LIMIT 3 | |
| inner_join(mtcars2, mtcars2, by = "cyl") %>% | |
| show_query() | |
| #> <SQL> | |
| #> SELECT `TBL_LEFT`.`mpg` AS `mpg.x`, `TBL_LEFT`.`cyl` AS `cyl`, `TBL_LEFT`.`disp` AS `disp.x`, `TBL_LEFT`.`hp` AS `hp.x`, `TBL_LEFT`.`drat` AS `drat.x`, `TBL_LEFT`.`wt` AS `wt.x`, `TBL_LEFT`.`qsec` AS `qsec.x`, `TBL_LEFT`.`vs` AS `vs.x`, `TBL_LEFT`.`am` AS `am.x`, `TBL_LEFT`.`gear` AS `gear.x`, `TBL_LEFT`.`carb` AS `carb.x`, `TBL_RIGHT`.`mpg` AS `mpg.y`, `TBL_RIGHT`.`disp` AS `disp.y`, `TBL_RIGHT`.`hp` AS `hp.y`, `TBL_RIGHT`.`drat` AS `drat.y`, `TBL_RIGHT`.`wt` AS `wt.y`, `TBL_RIGHT`.`qsec` AS `qsec.y`, `TBL_RIGHT`.`vs` AS `vs.y`, `TBL_RIGHT`.`am` AS `am.y`, `TBL_RIGHT`.`gear` AS `gear.y`, `TBL_RIGHT`.`carb` AS `carb.y` | |
| #> FROM `mtcars` AS `TBL_LEFT` | |
| #> INNER JOIN `mtcars` AS `TBL_RIGHT` | |
| #> ON (`TBL_LEFT`.`cyl` = `TBL_RIGHT`.`cyl`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment