Skip to content

Calling DBI::dbConnect(odbc::databricks()) a second time fails with Error in driver_config$path on MacOS #901

Open
@benesom

Description

@benesom

Establishing a odbc connection works as expect for

args <- list(
  odbc::databricks(),
  auth_accesstoken = token,
  workspace = workspace,
  authMech = 11,
  auth_flow = 0,
  HTTPPath = httppath
)
conn <- do.call(DBI::dbConnect, args)
> conn
<OdbcConnection> Spark SQL
  Database: foundata_investigations_bronze_prd
  Spark SQL Version: 3.5.0

However, trying to "re-connect" to the cluster fails

> do.call(DBI::dbConnect, args)
Error in driver_config$path : $ operator is invalid for atomic vectors

The traceback points at odbc:::configure_simba, which was introduced in odbc v.1.6.0

5: configure_simba(spark_simba_config(args$driver), action = "modify")
4: .local(drv, ...)
3: (new("standardGeneric", .Data = function (drv, ...) 
   {
       ans <- standardGeneric("dbConnect")
       .valueClassTest(ans, "DBIConnection", "dbConnect")
   }, generic = structure("dbConnect", package = "DBI"), package = "DBI", 
       group = list(), valueClass = "DBIConnection", signature = "drv", 
       default = NULL, skeleton = (function (drv, ...) 
       stop(gettextf("invalid call in method dispatch to '%s' (no default method)", 
           "dbConnect"), domain = NA))(drv, ...)))(new("DatabricksOdbcDriver", ), 
       auth_accesstoken = "xxxx", 
       workspace = "xxxx", 
       authMech = 11, auth_flow = 0, HTTPPath = "xxx")
2: (new("standardGeneric", .Data = function (drv, ...) 
   {
       ans <- standardGeneric("dbConnect")
       .valueClassTest(ans, "DBIConnection", "dbConnect")
   }, generic = structure("dbConnect", package = "DBI"), package = "DBI", 
       group = list(), valueClass = "DBIConnection", signature = "drv", 
       default = NULL, skeleton = (function (drv, ...) 
       stop(gettextf("invalid call in method dispatch to '%s' (no default method)", 
           "dbConnect"), domain = NA))(drv, ...)))(new("DatabricksOdbcDriver", ), 
       auth_accesstoken = "xxx", 
       workspace = "xxxx", 
       authMech = 11, auth_flow = 0, HTTPPath = "xxx")
1: do.call(DBI::dbConnect, args)
> sessionInfo()
R version 4.4.2 (2024-10-31)
Platform: aarch64-apple-darwin24.3.0
Running under: macOS Sequoia 15.3.1

Matrix products: default
BLAS:   /Users/xxxx/.asdf/installs/R/4.4.2/lib/R/lib/libRblas.dylib 
LAPACK: /Users/xxx/.asdf/installs/R/4.4.2/lib/R/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Copenhagen
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] odbc_1.6.0 DBI_1.2.3 

loaded via a namespace (and not attached):
 [1] bit_4.5.0.1     compiler_4.4.2  cli_3.6.4       hms_1.1.3      
 [5] Rcpp_1.0.14     bit64_4.6.0-1   vctrs_0.6.5     blob_1.2.4     
 [9] jsonlite_1.9.0  lifecycle_1.0.4 pkgconfig_2.0.3 rlang_1.1.5   

Installing

devtools::install_github("https://github.com/r-dbi/odbc", ref = "v1.5.0")

and re-running the previous example works as expected. That is, calling

do.call(DBI::dbConnect, args)

a second time will return a odbc connection. The error does not occur on linux, as a consequence of

configure_simba <- function(driver_config,
                            action = "modify", call = caller_env()) {
  if (!is_macos()) {
    return(invisible())
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions