Skip to main content

sandbox_commands

Creates, updates, deletes, gets or lists a sandbox_commands resource.

Overview​

Namesandbox_commands
TypeResource
Iddatabricks_workspace.sandbox.sandbox_commands

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
command_idstringStable identifier for this command.
argsarrayArguments passed to the program.
cmdstringThe program that was executed.
exit_codeintegerProcess exit code. Only present when finished is true and the process exited normally (not killed by signal or failed to start).
finishedbooleanWhether the command has finished executing.
pidintegerPID of the spawned process. Absent if the process failed to start.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectsandbox_id, deployment_name, workspace_domainpage_size, page_tokenLists the tracked command executions (running and completed) in a sandbox.
executeexecsandbox_id, deployment_name, workspace_domain, cmdRuns a command in the sandbox and blocks until it exits, returning the captured stdout, stderr and

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
deployment_namestringThe Databricks workspace deployment name: the host prefix of the workspace URL (dbc-abcd0123-a1bc on AWS, adb-1234567890123456.7 on Azure, 1234567890123456.7 on GCP). Set DATABRICKS_DEPLOYMENT_NAME to default it for the session. (default: dbc-abcd0123-a1bc, x-stackQL-envVar: DATABRICKS_DEPLOYMENT_NAME)
sandbox_idstringThe sandbox_id segment of the name resource name (sandboxes/{sandbox_id}). Resource name of the sandbox to run the command in, in the form sandboxes/{sandbox_id}. Bound from the URL path.
workspace_domainstringThe Databricks workspace domain suffix for the cloud. Selected by DATABRICKS_CLOUD (aws, azure or gcp; default aws). (default: cloud.databricks.com, x-stackQL-envVarSelector: {"envVar":"DATABRICKS_CLOUD","default":"aws","values":{"aws":"cloud.databricks.com","azure":"azuredatabricks.net","gcp":"gcp.databricks.com"}})
page_sizeintegerMaximum number of commands to return. The server may return fewer. If unspecified, the server returns all commands.
page_tokenstringPage token returned by a previous ListCommands call. Use this to retrieve the next page of results.

SELECT examples​

Lists the tracked command executions (running and completed) in a sandbox.

SELECT
command_id,
args,
cmd,
exit_code,
finished,
pid
FROM databricks_workspace.sandbox.sandbox_commands
WHERE sandbox_id = '{{ sandbox_id }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
AND workspace_domain = '{{ workspace_domain }}' -- required
AND page_size = '{{ page_size }}'
AND page_token = '{{ page_token }}'
;

Lifecycle Methods​

Runs a command in the sandbox and blocks until it exits, returning the captured stdout, stderr and

EXEC databricks_workspace.sandbox.sandbox_commands.execute
@sandbox_id='{{ sandbox_id }}' --required,
@deployment_name='{{ deployment_name }}' --required,
@workspace_domain='{{ workspace_domain }}' --required
@@json=
'{
"cmd": "{{ cmd }}",
"args": "{{ args }}",
"envs": "{{ envs }}",
"execution_timeout": "{{ execution_timeout }}"
}'
;