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

semi_join() / anti_join() do not correctly parse sql_on argument #443

Closed
cole-johanson opened this issue May 6, 2020 · 1 comment · Fixed by #456
Closed

semi_join() / anti_join() do not correctly parse sql_on argument #443

cole-johanson opened this issue May 6, 2020 · 1 comment · Fixed by #456
Labels
bug an unexpected problem or unintended behavior verb trans 🤖 Translation of dplyr verbs to SQL

Comments

@cole-johanson
Copy link

When using semi_join() and anti_join() in dbplyr, the sql_on= argument does not parse correctly. This is needed for more complicated joins than the by= argument can handle.

suppressMessages(library(dplyr))
suppressMessages(library(dbplyr))

x = memdb_frame(x=c(1,2))
x %>% left_join(x,sql_on='"LHS".x = "RHS".x') %>% show_query # works
#> <SQL>
#> SELECT `LHS`.`x` AS `x.x`, `RHS`.`x` AS `x.y`
#> FROM `dbplyr_001` AS `LHS`
#> LEFT JOIN `dbplyr_001` AS `RHS`
#> ON ("LHS".x = "RHS".x)

x %>% anti_join(x,by="x") %>% show_query # works
#> <SQL>
#> SELECT * FROM `dbplyr_001` AS `LHS`
#> WHERE NOT EXISTS (
#>   SELECT 1 FROM `dbplyr_001` AS `RHS`
#>   WHERE (`LHS`.`x` = `RHS`.`x`)
#> )

x %>% anti_join(x,sql_on='LHS".x = "RHS".x') %>% show_query # misses arguments
#> <SQL>
#> SELECT * FROM `dbplyr_001` AS `LHS`
#> WHERE NOT EXISTS (
#>   SELECT 1 FROM `dbplyr_001` AS `RHS`
#>   WHERE (`LHS`. = `RHS`.)
#> )

Created on 2020-05-06 by the reprex package (v0.3.0)

@hadley
Copy link
Member

hadley commented May 15, 2020

@krlmlr can you please take a look at this?

@hadley hadley added bug an unexpected problem or unintended behavior verb trans 🤖 Translation of dplyr verbs to SQL labels May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior verb trans 🤖 Translation of dplyr verbs to SQL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants