1st Degree Join

join1(
  conn,
  conn_fun,
  write_schema,
  data,
  column,
  select_table_fields = "*",
  select_join_on_fields = "*",
  join_on_schema,
  join_on_table,
  join_on_column,
  kind = c("LEFT", "RIGHT", "INNER", "FULL"),
  where_in_field,
  where_in_vector,
  where_in_join_on_field,
  where_in_join_on_vector,
  where_not_in_field,
  where_not_in_vector,
  where_not_in_join_on_field,
  where_not_in_join_on_vector,
  where_is_null_field,
  where_is_not_null_field,
  where_is_null_join_on_field,
  where_is_not_null_join_on_field,
  case_insensitive,
  distinct = FALSE,
  verbose = TRUE,
  render_sql = TRUE,
  render_only = FALSE
)

Examples

library(pg13) create_test_schema <- function(conn) { if (!schema_exists(conn = conn, schema = "test_schema")) { create_schema(conn = conn, schema = "test_schema") } } conn <- local_connect(dbname = "pg13_test")
#> Error in rJava::.jcall(jdbcDriver, "Ljava/sql/Connection;", "connect", as.character(url), p): org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
create_test_schema(conn = conn)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'conn' in selecting a method for function 'dbGetQuery': object 'conn' not found
# Write a table to join to without dropping write_table(conn = conn, schema = "test_schema", table_name = "test_table2", drop_existing = TRUE, data = data.frame(A = 1:25, B = letters[1:25]))
#> [2021-06-20 15:26:13] Dropping test_schema.test_table2...
#> Error in check_conn_status(conn = conn): object 'conn' not found
# Joining Test Data test_data <- data.frame(A = 1:100, B = letters[1:100]) test_data
#> A B #> 1 1 a #> 2 2 b #> 3 3 c #> 4 4 d #> 5 5 e #> 6 6 f #> 7 7 g #> 8 8 h #> 9 9 i #> 10 10 j #> 11 11 k #> 12 12 l #> 13 13 m #> 14 14 n #> 15 15 o #> 16 16 p #> 17 17 q #> 18 18 r #> 19 19 s #> 20 20 t #> 21 21 u #> 22 22 v #> 23 23 w #> 24 24 x #> 25 25 y #> 26 26 z #> 27 27 <NA> #> 28 28 <NA> #> 29 29 <NA> #> 30 30 <NA> #> 31 31 <NA> #> 32 32 <NA> #> 33 33 <NA> #> 34 34 <NA> #> 35 35 <NA> #> 36 36 <NA> #> 37 37 <NA> #> 38 38 <NA> #> 39 39 <NA> #> 40 40 <NA> #> 41 41 <NA> #> 42 42 <NA> #> 43 43 <NA> #> 44 44 <NA> #> 45 45 <NA> #> 46 46 <NA> #> 47 47 <NA> #> 48 48 <NA> #> 49 49 <NA> #> 50 50 <NA> #> 51 51 <NA> #> 52 52 <NA> #> 53 53 <NA> #> 54 54 <NA> #> 55 55 <NA> #> 56 56 <NA> #> 57 57 <NA> #> 58 58 <NA> #> 59 59 <NA> #> 60 60 <NA> #> 61 61 <NA> #> 62 62 <NA> #> 63 63 <NA> #> 64 64 <NA> #> 65 65 <NA> #> 66 66 <NA> #> 67 67 <NA> #> 68 68 <NA> #> 69 69 <NA> #> 70 70 <NA> #> 71 71 <NA> #> 72 72 <NA> #> 73 73 <NA> #> 74 74 <NA> #> 75 75 <NA> #> 76 76 <NA> #> 77 77 <NA> #> 78 78 <NA> #> 79 79 <NA> #> 80 80 <NA> #> 81 81 <NA> #> 82 82 <NA> #> 83 83 <NA> #> 84 84 <NA> #> 85 85 <NA> #> 86 86 <NA> #> 87 87 <NA> #> 88 88 <NA> #> 89 89 <NA> #> 90 90 <NA> #> 91 91 <NA> #> 92 92 <NA> #> 93 93 <NA> #> 94 94 <NA> #> 95 95 <NA> #> 96 96 <NA> #> 97 97 <NA> #> 98 98 <NA> #> 99 99 <NA> #> 100 100 <NA>
join1(conn = conn, write_schema = "public", data = test_data, column = "A", kind = "INNER", join_on_schema = "test_schema", join_on_table = "test_table2", join_on_column = "A")
#> [2021-06-20 15:26:13] Dropping public.V20210620152613...
#> Error in check_conn_status(conn = conn): object 'conn' not found
join1(conn = conn, write_schema = "public", data = test_data, column = "A", kind = "RIGHT", join_on_schema = "test_schema", join_on_table = "test_table2", join_on_column = "A")
#> [2021-06-20 15:26:13] Dropping public.V20210620152613...
#> Error in check_conn_status(conn = conn): object 'conn' not found
join1(conn = conn, write_schema = "public", data = test_data, column = "A", kind = "LEFT", join_on_schema = "test_schema", join_on_table = "test_table2", join_on_column = "A")
#> [2021-06-20 15:26:13] Dropping public.V20210620152613...
#> Error in check_conn_status(conn = conn): object 'conn' not found
join1(conn = conn, write_schema = "public", data = test_data, column = "A", kind = "FULL", join_on_schema = "test_schema", join_on_table = "test_table2", join_on_column = "A")
#> [2021-06-20 15:26:13] Dropping public.V20210620152613...
#> Error in check_conn_status(conn = conn): object 'conn' not found
drop_schema(conn = conn, schema = "test_schema", cascade = TRUE)
#> Error in check_conn_status(conn = conn): object 'conn' not found
dc(conn = conn)
#> [2021-06-20 15:26:13] Postgres connection was already closed