create_execution_context: Create an execution context for running commands on...

View source: R/create_execution_context.R

create_execution_contextR Documentation

Create an execution context for running commands on Databricks.

Description

This function provides the context for executing remote commands on an existing Databricks cluster via REST API. The output is intended to be passed to databricks_execute.

Usage

create_execution_context(
  workspace,
  cluster_id,
  language = "r",
  token = NULL,
  verbose = F
)

Arguments

workspace

A string representing the web workspace of your Databricks instance. E.g., "https://eastus2.azuredatabricks.net" or "https://demo.cloud.databricks.com".

cluster_id

A string containing the ID of an active Databricks cluster.

language

The language to execute commands in. The default is 'r', but can also be set to 'python', 'scala' and 'sql'.

token

A valid authentication token generated via User Settings in Databricks or via the Databricks REST API 2.0. If none is provided, netrc will be used.

verbose

If true, will pretty print the success or failure of the request. Defaults to FALSE.

Details

The API endpoint for creating the execution context is is '1.2/contexts/create'. For all details on API calls please see the official documentation at https://docs.databricks.com/dev-tools/api/latest/.

Value

A list with five elements:

  • language - The language to execute commands in.

  • cluster_id - ID of the active Databricks cluster.

  • context_id - ID of the execution context on the cluster.

  • workspace - The URL of the Databricks workspace.

  • token - The token used to authenticate.

Examples

# Using netrc
context <- create_execution_context(workspace = "https://eastus2.azuredatabricks.net",
                  language = "r",
                  cluster_id = "1017-337483-jars232")

## Use the context to execute a command on Databricks
command <- "iris[1, ]"
databricks_execute(command, context)


RafiKurlansik/bricksteR documentation built on Oct. 13, 2022, 6:58 a.m.