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

Join across different schemas #7

Open
saurav2608 opened this issue Apr 5, 2018 · 2 comments
Open

Join across different schemas #7

saurav2608 opened this issue Apr 5, 2018 · 2 comments

Comments

@saurav2608
Copy link

Is there a way to join two tables from different schemas? At this time I think one option is to set copy=TRUE in dplyr::left_join. However, copy has serious performance issues.

@ZacharyRSmith
Copy link

Using in_schema() works for me:

options(dplyr.jdbc.classpath = "~/Projects/carrothealth_r_package/data/snowflake-jdbc-3.6.21.jar")
library(dplyr)
library(dbplyr)
devtools::load_all()
my_db <- src_snowflakedb(user = "zach_s_admin",
                         password = "REDACTED",
                         account = "REDACTED",
                         opts = list(warehouse = "development_x_small",
                                     db = "WAREHOUSE",
                                     schema = "PUBLIC",
                                     role = "DEV_USERS"))
zips_w <- tbl(my_db, in_schema('WAREHOUSE.GEO', 'ZIPS'))
counties_s <- tbl(my_db, in_schema('STAGING.GEO', 'COUNTIES'))
inner_join(
  zips_w %>% filter(ZIP == 55414),
  counties_s
) %>% show_query()

@ZacharyRSmith
Copy link

ZacharyRSmith commented Apr 5, 2019

@saurav2608 for what it's worth, my repo handles the dbplyr::in_schema() for you: https://github.com/ZacharyRSmith/RSnowflake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants