odbc icon indicating copy to clipboard operation
odbc copied to clipboard

Automate `httpPath` by pulling from Databricks REST API

Open edgararuiz opened this issue 1 year ago • 6 comments

The Databricks REST API has a “SQL warehouse” endpoint, where you can pull the httpPath value from, here is an example using httr2, which I guess odbc would need to take a dependency against, unless y’all prefer to implement something like this at a lower level, here’s the example:

library(httr2)

warehouses <- paste0(
  Sys.getenv("DATABRICKS_HOST"),
  "/api/2.0/sql/warehouses"
) %>%
  request() %>%
  req_auth_bearer_token(Sys.getenv("DATABRICKS_TOKEN")) %>%
  req_perform() %>%
  resp_body_json()

# The path is in a specific location inside the object returned by the API
warehouses[[1]][[1]]$odbc_params$path

I was thinking it makes sense to automate seeing that it may be the only argument in databricks() that does not yet have a way, even in a happy path, for it to be automated.

edgararuiz avatar Dec 18 '23 21:12 edgararuiz