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

Ensure join/semi_join/set ops generate minimal SQL #236

Closed
hadley opened this issue Feb 6, 2019 · 0 comments
Closed

Ensure join/semi_join/set ops generate minimal SQL #236

hadley opened this issue Feb 6, 2019 · 0 comments
Labels
feature a feature request or enhancement verb trans 🤖 Translation of dplyr verbs to SQL
Milestone

Comments

@hadley
Copy link
Member

hadley commented Feb 6, 2019

library(dbplyr)
library(dplyr, warn.conflicts = FALSE)

lf <- lazy_frame(x = 1, y = 2)

union(lf, lf)
#> <SQL>
#> (SELECT *
#> FROM `df`)
#> UNION
#> (SELECT *
#> FROM `df`)
left_join(lf, lf)
#> Joining, by = c("x", "y")
#> <SQL>
#> SELECT `TBL_LEFT`.`x` AS `x`, `TBL_LEFT`.`y` AS `y`
#>   FROM (SELECT *
#> FROM `df`) `TBL_LEFT`
#>   LEFT JOIN (SELECT *
#> FROM `df`) `TBL_RIGHT`
#>   ON (`TBL_LEFT`.`x` = `TBL_RIGHT`.`x` AND `TBL_LEFT`.`y` = `TBL_RIGHT`.`y`)
anti_join(lf, lf)
#> Joining, by = c("x", "y")
#> <SQL>
#> SELECT * FROM (SELECT *
#> FROM `df`) `TBL_LEFT`
#> 
#> WHERE NOT EXISTS (
#>   SELECT 1 FROM (SELECT *
#> FROM `df`) `TBL_RIGHT`
#>   WHERE (`TBL_LEFT`.`x` = `TBL_RIGHT`.`x` AND `TBL_LEFT`.`y` = `TBL_RIGHT`.`y`)
#> )

Created on 2019-02-06 by the reprex package (v0.2.1.9000)

@hadley hadley added feature a feature request or enhancement verb trans 🤖 Translation of dplyr verbs to SQL labels Feb 6, 2019
@hadley hadley added this to the v1.4.0 milestone Feb 6, 2019
@hadley hadley closed this as completed in b7e962e Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement verb trans 🤖 Translation of dplyr verbs to SQL
Projects
None yet
Development

No branches or pull requests

1 participant