sandbox_commands
Creates, updates, deletes, gets or lists a sandbox_commands resource.
Overview​
| Name | sandbox_commands |
| Type | Resource |
| Id | databricks_workspace.sandbox.sandbox_commands |
Fields​
The following fields are returned by SELECT queries:
- list
| Name | Datatype | Description |
|---|---|---|
command_id | string | Stable identifier for this command. |
args | array | Arguments passed to the program. |
cmd | string | The program that was executed. |
exit_code | integer | Process exit code. Only present when finished is true and the process exited normally (not killed by signal or failed to start). |
finished | boolean | Whether the command has finished executing. |
pid | integer | PID of the spawned process. Absent if the process failed to start. |
Methods​
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | sandbox_id, deployment_name, workspace_domain | page_size, page_token | Lists the tracked command executions (running and completed) in a sandbox. |
execute | exec | sandbox_id, deployment_name, workspace_domain, cmd | Runs 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.
| Name | Datatype | Description |
|---|---|---|
deployment_name | string | The 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_id | string | The 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_domain | string | The 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_size | integer | Maximum number of commands to return. The server may return fewer. If unspecified, the server returns all commands. |
page_token | string | Page token returned by a previous ListCommands call. Use this to retrieve the next page of results. |
SELECT examples​
- list
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​
- execute
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 }}"
}'
;