Skip to main content

command_execution

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

Overview​

Namecommand_execution
TypeResource
Iddatabricks_workspace.compute.command_execution

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstring
â–¶resultsobject
statusstringCreate a collection of name/value pairs.<br /><br />Example enumeration:<br /><br />&gt;&gt;&gt; class Color(Enum):<br />... RED = 1<br />... BLUE = 2<br />... GREEN = 3<br /><br />Access them by:<br /><br />- attribute access:<br /><br /> &gt;&gt;&gt; Color.RED<br /> &lt;Color.RED: 1&gt;<br /><br />- value lookup:<br /><br /> &gt;&gt;&gt; Color(1)<br /> &lt;Color.RED: 1&gt;<br /><br />- name lookup:<br /><br /> &gt;&gt;&gt; Color['RED']<br /> &lt;Color.RED: 1&gt;<br /><br />Enumerations can be iterated over, and know how many members they have:<br /><br />&gt;&gt;&gt; len(Color)<br />3<br /><br />&gt;&gt;&gt; list(Color)<br />[&lt;Color.RED: 1&gt;, &lt;Color.BLUE: 2&gt;, &lt;Color.GREEN: 3&gt;]<br /><br />Methods can be added to enumerations, and members can have their own<br />attributes -- see the documentation for details. (Cancelled, Cancelling, Error, Finished, Queued, Running)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
command_statusselectcluster_id, context_id, command_id, deployment_name, workspace_domainGets the status of and, if available, the results from a currently executing command.
createinsertdeployment_name, workspace_domainCreates an execution context for running cluster commands.
cancelexecdeployment_name, workspace_domainCancels a currently running command within an execution context.
destroyexecdeployment_name, workspace_domain, clusterId, contextIdDeletes an execution context.
executeexecdeployment_name, workspace_domainRuns a cluster command in the given execution context, using the provided language.

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
cluster_idstring
command_idstring
context_idstring
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)
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"}})

SELECT examples​

Gets the status of and, if available, the results from a currently executing command.

SELECT
id,
results,
status
FROM databricks_workspace.compute.command_execution
WHERE cluster_id = '{{ cluster_id }}' -- required
AND context_id = '{{ context_id }}' -- required
AND command_id = '{{ command_id }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
AND workspace_domain = '{{ workspace_domain }}' -- required
;

INSERT examples​

Creates an execution context for running cluster commands.

INSERT INTO databricks_workspace.compute.command_execution (
clusterId,
language,
deployment_name,
workspace_domain
)
SELECT
'{{ clusterId }}',
'{{ language }}',
'{{ deployment_name }}',
'{{ workspace_domain }}'
RETURNING
id,
status
;

Lifecycle Methods​

Cancels a currently running command within an execution context.

EXEC databricks_workspace.compute.command_execution.cancel
@deployment_name='{{ deployment_name }}' --required,
@workspace_domain='{{ workspace_domain }}' --required
@@json=
'{
"clusterId": "{{ clusterId }}",
"commandId": "{{ commandId }}",
"contextId": "{{ contextId }}"
}'
;