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

DatabaseConnector support #1583

Open
ablack3 opened this issue Feb 19, 2025 · 0 comments
Open

DatabaseConnector support #1583

ablack3 opened this issue Feb 19, 2025 · 0 comments

Comments

@ablack3
Copy link
Contributor

ablack3 commented Feb 19, 2025

DatabaseConnector is DBI driver backend that supports multiple database systems using jdbc.

We would like to make sure dplyr sql translation dispatches correctly when using DatabaseConnector connections with dbplyr.

The approach we are trying is to define a translation environment for these connection in DatabaseConnector as follows.

#' @export
#' @importFrom dbplyr sql_translation 
sql_translation.DatabaseConnectorJdbcConnection <- function(con) {
  
  switch(dbms(con),
     "oracle" = utils::getFromNamespace("sql_translation.Oracle", "dbplyr")(con),
     "postgresql" = utils::getFromNamespace("sql_translation.PqConnection", "dbplyr")(con),
     "redshift" = utils::getFromNamespace("sql_translation.RedshiftConnection", "dbplyr")(con),
     "sql server" = utils::getFromNamespace("sql_translation.Microsoft SQL Server", "dbplyr")(con),
     "bigquery" = utils::getFromNamespace("sql_translation.BigQueryConnection", "bigrquery")(con),
     "spark" = utils::getFromNamespace("sql_translation.Spark SQL", "dbplyr")(con),
     "snowflake" = utils::getFromNamespace("sql_translation.Snowflake", "dbplyr")(con),
     "synapse" = utils::getFromNamespace("sql_translation.Microsoft SQL Server", "dbplyr")(con),
     rlang::abort("Sql dialect is not supported!")) 
}

Is this the best way to add dplyr support or should we add something to dbplyr to dispatch the correct translation environment.

We also found we needed to write the method sql_query_select.DatabaseConnectorJdbcConnection as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant