Skip to main content

clusters

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

Overview

Nameclusters
TypeResource
Iddatabricks_workspace.compute.clusters

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
cluster_idstring
driver_node_type_idstring
node_type_idstring
spark_context_idinteger
cluster_namestring
creator_user_namestring
autotermination_minutesinteger
aws_attributesobject
cluster_sourcestring
default_tagsobject
disk_specobject
driver_instance_sourceobject
enable_elastic_diskboolean
enable_local_disk_encryptionboolean
init_scripts_safe_modeboolean
instance_sourceobject
last_state_loss_timeinteger
num_workersinteger
spark_versionstring
start_timeinteger
statestring
state_messagestring
terminated_timeinteger
termination_reasonobject

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectdeployment_nameReturn information about all pinned and active clusters, and all clusters terminated within the last 30 days. Clusters terminated prior to this period are not included.
getselectdeployment_nameRetrieves the information for a cluster given its identifier. Clusters can be described while they are running, or up to 60 days after they are terminated.
createinsertdeployment_nameCreates a new Spark cluster. This method will acquire new instances from the cloud provider if necessary. This method is asynchronous; the returned
updateupdatedeployment_nameUpdates the configuration of a cluster to match the partial set of attributes and size. Denote which fields to update using the
editreplacedeployment_nameUpdates the configuration of a cluster to match the provided attributes and size. A cluster can be updated if it is in a
deletedeletedeployment_nameTerminates the Spark cluster with the specified ID. The cluster is removed asynchronously. Once the termination has completed, the cluster will be in a
changeownerexecdeployment_nameChange the owner of the cluster. You must be an admin and the cluster must be terminated to perform this operation. The service principal application ID can be supplied as an argument to
permanentdeleteexecdeployment_namePermanently deletes a Spark cluster. This cluster is terminated and resources are asynchronously removed.
pinexecdeployment_namePinning a cluster ensures that the cluster will always be returned by the ListClusters API. Pinning a cluster that is already pinned will have no effect. This API can only be called by workspace admins.
resizeexecdeployment_nameResizes a cluster to have a desired number of workers. This will fail unless the cluster is in a
restartexecdeployment_nameRestarts a Spark cluster with the supplied ID. If the cluster is not currently in a
startexecdeployment_nameStarts a terminated Spark cluster with the supplied ID. This works similar to
unpinexecdeployment_nameUnpinning a cluster will allow the cluster to eventually be removed from the ListClusters API. Unpinning a cluster that is not pinned will have no effect. This API can only be called by workspace admins.

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 (default: dbc-abcd0123-a1bc)

SELECT examples

Return information about all pinned and active clusters, and all clusters terminated within the last 30 days. Clusters terminated prior to this period are not included.

SELECT
cluster_id,
driver_node_type_id,
node_type_id,
spark_context_id,
cluster_name,
creator_user_name,
autotermination_minutes,
aws_attributes,
cluster_source,
default_tags,
disk_spec,
driver_instance_source,
enable_elastic_disk,
enable_local_disk_encryption,
init_scripts_safe_mode,
instance_source,
last_state_loss_time,
num_workers,
spark_version,
start_time,
state,
state_message,
terminated_time,
termination_reason
FROM databricks_workspace.compute.clusters
WHERE deployment_name = '{{ deployment_name }}' -- required;

INSERT examples

Creates a new Spark cluster. This method will acquire new instances from the cloud provider if necessary. This method is asynchronous; the returned

INSERT INTO databricks_workspace.compute.clusters (
data__num_workers,
data__kind,
data__cluster_name,
data__spark_version,
data__use_ml_runtime,
data__is_single_node,
data__node_type_id,
data__driver_node_type_id,
data__ssh_public_keys,
data__autotermination_minutes,
data__enable_elastic_disk,
data__instance_pool_id,
data__policy_id,
data__enable_local_disk_encryption,
data__driver_instance_pool_id,
data__runtime_engine,
data__data_security_mode,
data__single_user_name,
data__apply_policy_default_values,
data__autoscale,
data__spark_conf,
data__aws_attributes,
data__custom_tags,
data__cluster_log_conf,
data__init_scripts,
data__spark_env_vars,
data__workload_type,
data__docker_image,
data__clone_from,
deployment_name
)
SELECT
'{{ num_workers }}',
'{{ kind }}',
'{{ cluster_name }}',
'{{ spark_version }}',
'{{ use_ml_runtime }}',
{{ is_single_node }},
{{ node_type_id }},
'{{ driver_node_type_id }}',
'{{ ssh_public_keys }}',
'{{ autotermination_minutes }}',
'{{ enable_elastic_disk }}',
{{ instance_pool_id }},
'{{ policy_id }}',
'{{ enable_local_disk_encryption }}',
{{ driver_instance_pool_id }},
'{{ runtime_engine }}',
'{{ data_security_mode }}',
'{{ single_user_name }}',
'{{ apply_policy_default_values }}',
'{{ autoscale }}',
'{{ spark_conf }}',
'{{ aws_attributes }}',
'{{ custom_tags }}',
'{{ cluster_log_conf }}',
'{{ init_scripts }}',
'{{ spark_env_vars }}',
'{{ workload_type }}',
'{{ docker_image }}',
'{{ clone_from }}',
'{{ deployment_name }}'
RETURNING
cluster_id
;

UPDATE examples

Updates the configuration of a cluster to match the partial set of attributes and size. Denote which fields to update using the

UPDATE databricks_workspace.compute.clusters
SET
data__cluster_id = '{{ cluster_id }}',
data__update_mask = '{{ update_mask }}',
data__cluster = '{{ cluster }}'
WHERE
deployment_name = '{{ deployment_name }}' --required;

REPLACE examples

Updates the configuration of a cluster to match the provided attributes and size. A cluster can be updated if it is in a

REPLACE databricks_workspace.compute.clusters
SET
data__cluster_id = '{{ cluster_id }}',
data__num_workers = '{{ num_workers }}',
data__kind = '{{ kind }}',
data__cluster_name = '{{ cluster_name }}',
data__spark_version = '{{ spark_version }}',
data__use_ml_runtime = '{{ use_ml_runtime }}',
data__is_single_node = '{{ is_single_node }}',
data__node_type_id = {{ node_type_id }},
data__driver_node_type_id = {{ driver_node_type_id }},
data__ssh_public_keys = '{{ ssh_public_keys }}',
data__autotermination_minutes = '{{ autotermination_minutes }}',
data__enable_elastic_disk = '{{ enable_elastic_disk }}',
data__instance_pool_id = '{{ instance_pool_id }}',
data__policy_id = {{ policy_id }},
data__enable_local_disk_encryption = '{{ enable_local_disk_encryption }}',
data__driver_instance_pool_id = '{{ driver_instance_pool_id }}',
data__runtime_engine = {{ runtime_engine }},
data__data_security_mode = '{{ data_security_mode }}',
data__single_user_name = '{{ single_user_name }}',
data__apply_policy_default_values = '{{ apply_policy_default_values }}',
data__autoscale = '{{ autoscale }}',
data__spark_conf = '{{ spark_conf }}',
data__aws_attributes = '{{ aws_attributes }}',
data__custom_tags = '{{ custom_tags }}',
data__cluster_log_conf = '{{ cluster_log_conf }}',
data__init_scripts = '{{ init_scripts }}',
data__spark_env_vars = '{{ spark_env_vars }}',
data__workload_type = '{{ workload_type }}',
data__docker_image = '{{ docker_image }}'
WHERE
deployment_name = '{{ deployment_name }}' --required;

DELETE examples

Terminates the Spark cluster with the specified ID. The cluster is removed asynchronously. Once the termination has completed, the cluster will be in a

DELETE FROM databricks_workspace.compute.clusters
WHERE deployment_name = '{{ deployment_name }}' --required;

Lifecycle Methods

Change the owner of the cluster. You must be an admin and the cluster must be terminated to perform this operation. The service principal application ID can be supplied as an argument to

EXEC databricks_workspace.compute.clusters.changeowner 
@deployment_name='{{ deployment_name }}' --required
@@json=
'{
"cluster_id": "{{ cluster_id }}",
"owner_username": "{{ owner_username }}"
}';