An R package to connect to databricks
Mar 13, 2025
{sparklyr}
alone didn’t work (for me)get
s the function and thus activates itsc_conn <- function() {
check_vars()
sparklyr::spark_connect(
master = Sys.getenv("DATABRICKS_HOST"),
cluster_id = Sys.getenv("DATABRICKS_CLUSTER_ID"),
token = Sys.getenv("DATABRICKS_TOKEN"),
envname = Sys.getenv("DATABRICKS_VENV"),
app_name = "sconn_sparklyr",
method = "databricks_connect"
)
}
.onLoad <- function(...) {
.conns <<- rlang::new_environment()
rlang::env_bind_lazy(.conns, sc = sc_conn())
}
library()
/load_all()
) the package should lazily bind a connection function to the .conns
environmentsc()
, this function is activated by rlang::env_get()
.onLoad
work the way I expect it to?env_get
always have to activate the connection?spark_connection_is_open()
function triggers it)view slides at the-strategy-unit.github.io/data_science/presentations