Skip to content

Instantly share code, notes, and snippets.

@infotroph
Last active January 14, 2018 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infotroph/0a75bd9a2f04d1f61dc2b00e23764581 to your computer and use it in GitHub Desktop.
Save infotroph/0a75bd9a2f04d1f61dc2b00e23764581 to your computer and use it in GitHub Desktop.
join hangs on empty suffix
library(dplyr)
a = data.frame(id=1:3, x=1:3)
## local join: works as expected
inner_join(a, a, by="id", suffix=c(".1", ".2"))
# id x.1 x.2
# 1 1 1 1
# 2 2 2 2
# 3 3 3 3
inner_join(a, a, by="id", suffix=c("", ".2"))
# id x x.2
# 1 1 1 1
# 2 2 2 2
# 3 3 3 3
inner_join(a, a, by="id", suffix=c("1.", ""))
# id x1. x
# 1 1 1 1
# 2 2 2 2
# 3 3 3 3
## db connection: empty suffix hangs join
con = DBI::dbConnect(RSQLite::SQLite(), path = ":memory:")
copy_to(con, a, "a", temporary=F)
a_db = tbl(con, "a")
inner_join(a_db, a_db, by="id", suffix=c(".1", ".2"))
# # Source: lazy query [?? x 3]
# # Database: sqlite 3.19.3 []
# id x.1 x.2
# <int> <int> <int>
# 1 1 1 1
# 2 2 2 2
# 3 3 3 3
inner_join(a_db, a_db, by="id", suffix=c("", ".2"))
# hangs until killed
inner_join(a_db, a_db, by="id", suffix=c("1.", ""))
# hangs until killed
## LHS local, RHS db: works as expected
inner_join(a, a_db, copy=TRUE, by="id", suffix=c(".1", ".2"))
# id x.1 x.2
# 1 1 1 1
# 2 2 2 2
# 3 3 3 3
inner_join(a, a_db, copy=TRUE, by="id", suffix=c("", ".2"))
# id x x.2
# 1 1 1 1
# 2 2 2 2
# 3 3 3 3
inner_join(a, a_db, copy=TRUE, by="id", suffix=c("1.", ""))
# id x1. x
# 1 1 1 1
# 2 2 2 2
# 3 3 3 3
## LHS db, RHS local: empty suffix hangs join
inner_join(a_db, a, copy=TRUE, by="id", suffix=c(".1", ".2"))
# Source: lazy query [?? x 3]
# Database: sqlite 3.19.3 []
# id x.1 x.2
# <int> <int> <int>
# 1 1 1 1
# 2 2 2 2
# 3 3 3 3
inner_join(a_db, a, copy=TRUE, by="id", suffix=c("", ".2"))
# hangs until killed
inner_join(a_db, a, copy=TRUE, by="id", suffix=c("1.", ""))
# hangs until killed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment