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

Error to use pool and left_join without suffixes #111

Closed
ppagnone opened this issue Nov 11, 2020 · 4 comments
Closed

Error to use pool and left_join without suffixes #111

ppagnone opened this issue Nov 11, 2020 · 4 comments

Comments

@ppagnone
Copy link

ppagnone commented Nov 11, 2020

Hi, I was updating my package and a query which worked well with previous version is throwing exception if "suffix" param is not pass to left_join() function , altought "suffix" has a default value.

Error:

Error in UseMethod("sql_join_suffix") : 
  no applicable method for 'sql_join_suffix' applied to an object of class "c('Pool', 'R6')"

Code example:

pool <- dbPool(
    drv =RMariaDB::MariaDB(),
    user = myConfig$database$user,
    password = myConfig$database$password,
    host = myConfig$database$host,
    dbname = myConfig$database$dbname
  )

### Old query working previous update of package and throwing exception now:

query <- tbl(pool, "users") %>%  left_join(tbl(pool, "user_role"), by="user_id")

### This is working with last version
query <- tbl(pool, "users") %>% left_join(tbl(pool, "user_role"), by="user_id", suffix = c("a","b"))

Thanks in advance!

@dietrichson
Copy link

dietrichson commented Nov 11, 2020

Reproducible example based on example code:

library(pool)
library(dplyr)
library(dbplyr)
pool <- dbPool(
  drv = RMySQL::MySQL(),
  dbname = "shinydemo",
  host = "shiny-demo.csa7qlmguqrf.us-east-1.rds.amazonaws.com",
  username = "guest",
  password = "guest"
)
City <- tbl(pool,"City")
Country <- tbl(pool, "Country")
City %>% 
  left_join(Country, by = c("CountryCode" = "Code"))`
Error in UseMethod("sql_join_suffix") : 
  no applicable method for 'sql_join_suffix' applied to an object of class "c('Pool', 'R6')"

@burgerga
Copy link

burgerga commented Jan 5, 2021

@hadley Caused by tidyverse/dbplyr@6e64685

Possible fix/workaround is to define

sql_join_suffix.default <- function(con, ...) {
  c(".x", ".y")
}

@jcheng5
Copy link
Member

jcheng5 commented Jan 13, 2021

Thanks for the report, should be all set on master now!

@henrique1008
Copy link

henrique1008 commented Feb 16, 2023

Hi, today this happened with me

If I try this , everything works
query <- tbl(pool, "users") %>% left_join(tbl(pool, "user_role"), by="user_id", suffix = c("a","b"))

but if I try this

### This is working with last version
query <- tbl(pool, "users") %>% left_join(tbl(pool, "user_role"), by="user_id")

I receive this error

Error in UseMethod("sql_join_suffix") : 
  no applicable method for 'sql_join_suffix' applied to an object of class "c('Pool', 'R6')"

Therefore add suffix = c("a","b") make the code works, even if you don't have any duplicate variables other than those used for the join

It starts this morning for me

versions

pool 1.0.0
dplyr 1.1.0
dbplyr 2.3.0

I copied the exemplo of ppagnore up here, but I use Postgres backend, but I think this don´t mattters in this case

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

5 participants