Skip to main content

workspace

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

Overview​

Nameworkspace
TypeResource
Iddatabricks_workspace.workspace.workspace

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
object_idintegerUnique identifier for the object.
resource_idstringA unique identifier for the object that is consistent across all Databricks APIs.
created_atintegerOnly applicable to files. The creation UTC timestamp.
â–¶directory_infoobjectAdditional metadata about the directory. Only set for objects of type ``DIRECTORY``.
languagestringThe language of the object. This value is set only if the object type is ``NOTEBOOK``. For Jupyter (.ipynb) notebooks, this is always ``PYTHON``. (PYTHON, R, SCALA, SQL)
modified_atintegerOnly applicable to files, the last modified UTC timestamp.
object_typestringThe type of the object in workspace. - ``NOTEBOOK``: document that contains runnable code, visualizations, and explanatory text. - ``DIRECTORY``: directory - ``LIBRARY``: library - ``FILE``: file - ``REPO``: repository - ``DASHBOARD``: Lakeview dashboard (DASHBOARD, DIRECTORY, FILE, LIBRARY, NOTEBOOK, REPO)
pathstringThe absolute path of the object.
sizeintegerOnly applicable to files. The file size in bytes can be returned.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectpath, deployment_name, workspace_domainnotebooks_modified_afterLists the contents of a directory, or the object if it is not a directory. If the input path does not
deleteexecdeployment_name, workspace_domain, pathDeletes an object or a directory (and optionally recursively deletes all objects in the directory).
exportexecpath, deployment_name, workspace_domainformatExports an object or the contents of an entire directory.
importexecdeployment_name, workspace_domain, pathImports a workspace object (for example, a notebook or file) or the contents of an entire directory.
mkdirsexecdeployment_name, workspace_domain, pathCreates the specified directory (and necessary parent directories if they do not exist). If there is

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)
pathstringThe absolute path of the object or directory. Exporting a directory is only supported for the DBC, SOURCE, and AUTO format.
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"}})
formatstringThis specifies the format of the exported file. By default, this is SOURCE. The value is case sensitive. - SOURCE: The notebook is exported as source code. Directory exports will not include non-notebook entries. - HTML: The notebook is exported as an HTML file. - JUPYTER: The notebook is exported as a Jupyter/IPython Notebook file. - DBC: The notebook is exported in Databricks archive format. Directory exports will not include non-notebook entries. - R_MARKDOWN: The notebook is exported to R Markdown format. - AUTO: The object or directory is exported depending on the objects type. Directory exports will include notebooks and workspace files.
notebooks_modified_afterintegerUTC timestamp in milliseconds

SELECT examples​

Lists the contents of a directory, or the object if it is not a directory. If the input path does not

SELECT
object_id,
resource_id,
created_at,
directory_info,
language,
modified_at,
object_type,
path,
size
FROM databricks_workspace.workspace.workspace
WHERE path = '{{ path }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
AND workspace_domain = '{{ workspace_domain }}' -- required
AND notebooks_modified_after = '{{ notebooks_modified_after }}'
;

Lifecycle Methods​

Deletes an object or a directory (and optionally recursively deletes all objects in the directory).

EXEC databricks_workspace.workspace.workspace.delete
@deployment_name='{{ deployment_name }}' --required,
@workspace_domain='{{ workspace_domain }}' --required
@@json=
'{
"path": "{{ path }}",
"recursive": {{ recursive }}
}'
;