Skip to content

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

Description

@cole-johanson

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviordplyr verbs 🤖Translation of dplyr verbs to SQL

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions