Skip to main content

global_init_scripts

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

Overview

Nameglobal_init_scripts
TypeResource
Iddatabricks_workspace.compute.global_init_scripts

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringThe name of the script
script_idstringThe global init script ID.
created_atinteger
created_bystringThe username of the user who created the script.
enabledbooleanSpecifies whether the script is enabled. The script runs only if enabled.
positionintegerThe position of a script, where 0 represents the first script to run, 1 is the second script to run, in ascending order.
scriptstringThe Base64-encoded content of the script.
updated_atintegerTime when the script was updated, represented as a Unix timestamp in milliseconds.
updated_bystringThe username of the user who last updated the script

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectscript_id, deployment_nameGets all the details of a script, including its Base64-encoded contents.
listselectdeployment_nameGet a list of all global init scripts for this workspace. This returns all properties for each script
createinsertdeployment_name, name, scriptCreates a new global init script in this workspace.
updateupdatescript_id, deployment_name, name, scriptUpdates a global init script, specifying only the fields to change. All fields are optional.
deletedeletescript_id, deployment_nameDeletes a global init script.

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)
script_idstringThe ID of the global init script.

SELECT examples

Gets all the details of a script, including its Base64-encoded contents.

SELECT
name,
script_id,
created_at,
created_by,
enabled,
position,
script,
updated_at,
updated_by
FROM databricks_workspace.compute.global_init_scripts
WHERE script_id = '{{ script_id }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
;

INSERT examples

Creates a new global init script in this workspace.

INSERT INTO databricks_workspace.compute.global_init_scripts (
name,
script,
enabled,
position,
deployment_name
)
SELECT
'{{ name }}' /* required */,
'{{ script }}' /* required */,
{{ enabled }},
{{ position }},
'{{ deployment_name }}'
RETURNING
script_id
;

UPDATE examples

Updates a global init script, specifying only the fields to change. All fields are optional.

UPDATE databricks_workspace.compute.global_init_scripts
SET
name = '{{ name }}',
script = '{{ script }}',
enabled = {{ enabled }},
position = {{ position }}
WHERE
script_id = '{{ script_id }}' --required
AND deployment_name = '{{ deployment_name }}' --required
AND name = '{{ name }}' --required
AND script = '{{ script }}' --required;

DELETE examples

Deletes a global init script.

DELETE FROM databricks_workspace.compute.global_init_scripts
WHERE script_id = '{{ script_id }}' --required
AND deployment_name = '{{ deployment_name }}' --required
;