I'm working on a fork of the RSQLServer
package and am trying to implement joins. With the current version of the package, joins for any DBI-connected database are implemented using sql_join.DBIConnection
. However, that implementation doesn't work well for SQL server. For instance, it makes use of USING
which is not supported by SQL server.
I've got a version of this function sql_join.SQLServerConnection
working (though not complete yet). I've based my function on sql_join.DBIConnection
as much as possible. One issue I've had is that sql_join.DBIConnection
calls a number of non-exported functions within dplyr
such as common_by
. For now, I've worked around this by using dplyr:::common_by
, but I'm aware that that's not ideal practice.
Should I:
- Ask Hadley Wickham/Romain Francois to export the relevant functions to make life easier for people developing packages that build on
dplyr
? - Copy the internal functions into the package I'm working on?
- Continue to use the
:::
operator to call the functions? - Something else?
Clearly with option 3, there's a chance that the interface will change (since they're not exported functions) and that the package would break in the longer term.
Sample code:
sql_join.SQLServerConnection <- function (con, x, y, type = "inner", by = NULL, ...) {
join <- switch(type, left = sql("LEFT"), inner = sql("INNER"),
right = sql("RIGHT"), full = sql("FULL"), stop("Unknown join type:",
type, call. = FALSE))
by <- dplyr:::common_by(by, x, y)
using <- FALSE # all(by$x == by$y)
x_names <- dplyr:::auto_names(x$select)
y_names <- dplyr:::auto_names(y$select)
# more code
}
sql_join
with:::
. Please take a look at this pull request. My guess is there is a very high probability that it should work with SQL Server right out of the box. – akhmeddplyr
function with:::
instead of re-implementing it. – akhmed