Skip to content

Support for custom env var when passing user token in DBI::dbConnect(odbc::databricks()) #929

Description

@JavOrraca

Connecting to a serverless SQL warehouse from a user access token with odbc::databricks() requires setting the Databricks token to a global environment variable named DATABRICKS_TOKEN. If a user has their PAT assigned to the global env var DATABRICKS_TOKEN:

# This works
conn_1 <- DBI::dbConnect(
  odbc::databricks(),
  workspace = "https://some-corp.cloud.databricks.com",
  httpPath = "sql/1.0/warehouse/e123456789101112"
)

# This also works
conn_2 <- DBI::dbConnect(
  odbc::databricks(),
  workspace = "https://some-corp.cloud.databricks.com",
  token = Sys.getenv("DATABRICKS_TOKEN"),
  httpPath = "sql/1.0/warehouse/e123456789101112"
)

However, the code below fails even if DATABRICKS_TOKEN_LAB is set in the .Renviron with the user's correct PAT:

# This fails because token is not specifically calling an env var named DATABRICKS_TOKEN
conn_3 <- DBI::dbConnect(
  odbc::databricks(),
  workspace = "https://some-corp.cloud.databricks.com",
  token = Sys.getenv("DATABRICKS_TOKEN_LAB"), 
  httpPath = "sql/1.0/warehouse/e123456789101112"
)

I work with five (💀) Databricks instances at work so being able to connect to the different endpoints (all w/ different PATs) using different env var names would be very helpful. Thanks!

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