tidyquery
tidyquery copied to clipboard
Add support for cross joins
After the fix to https://github.com/tidyverse/dplyr/issues/4206 is on CRAN, use it to enable cross joins by specifying by = character()
.
cross join
does not work in query() functions
Codes like this does not work.
query (' select * from df1 cross join df2 where df1. = df2. ')
In the version of dplyr currently on CRAN, it is possible to do a cross join with full_join(..., by = character())
.
dplyr 1.1.0 (due to be submitted in CRAN in late January) will add a cross_join()
function and soft-deprecate the above syntax (https://github.com/tidyverse/dplyr/pull/6612).
~~I intend to make tidyquery require dplyr >= 1.1.0 and implement a translation of SQL CROSS JOIN
to dplyr cross_join()
.~~
Update: See my comment below.
queryparser already supports cross joins so this does not require any work there.
I intend to make tidyquery require dplyr >= 1.1.0 and implement a translation of SQL
CROSS JOIN
to dplyrcross_join()
.queryparser already supports cross joins so this does not require any work there.
Does it mean CROSS JOIN
will come true in tidyquery after dplyr >= 1.1.0 is released?
@antonio-yu I went ahead and added support for cross joins in https://github.com/ianmcook/tidyquery/commit/537eb354c75009b078a107c4c83c3226e40fae33. Please test it out and let me know if it works for you using the version of tidyquery on GitHub: remotes::install_github("ianmcook/tidyquery")
Cross joins should work in tidyquery now as long as you are using dplyr 1.0.0 or higher. I added code that detects what version of dplyr you are using. If are using an old version of dplyr that does not have the cross_join()
function, then it translates SQL cross join to full_join(..., by = character())
. If you are using the new dplyr that has cross_join(),
then it translates to that.