Sub topic 4
Access modes and data governance with Unity Catalog
This chapter assumes you know what a cluster's driver and workers are, and that you have used Unity Catalog (UC) objects such as catalogs, schemas, and tables. It covers the setting that decides whether a cluster can enforce UC permissions: the access mode.
What an access mode controls
An access mode is a cluster setting that decides who can use the cluster, which languages they can run, and whether Unity Catalog governance applies to the code. In the Clusters API this setting is the field data_security_mode.
Governance depends on isolation. If users share a cluster and can run arbitrary code on the same machines, one user's code could read another user's credentials or bypass table permissions. Access modes control how much isolation Databricks provides.
The main modes
| UI name | API value | Users | Languages | Unity Catalog |
|---|---|---|---|---|
| Standard (formerly shared) | `USER_ISOLATION` | Many | SQL, Python, Scala (Scala support depends on runtime version) | Supported, with enforcement |
| Dedicated (formerly single user) | `SINGLE_USER` | One user or one group | SQL, Python, Scala, R | Supported |
| No isolation shared | `NONE` | Many | All | Not supported |
Names and available features change between releases. Check the current documentation for your cloud and runtime version.
Standard mode isolates each user's code from the others. Databricks enforces UC permissions for every query, so many people can share one cluster and still see only the data they are granted.
Dedicated mode assigns the cluster to one user or one group. Because only that identity runs code, the cluster does not need to isolate users from one another. It is the usual choice for workloads that need features standard mode restricts, such as some machine learning libraries or R.
No isolation shared mode gives no protection between users and cannot access UC data. It exists for legacy workloads.
Setting the mode in code
The data_security_mode field appears in the cluster definition. This request creates a standard-mode cluster:
{
"cluster_name": "team-interactive",
"spark_version": "15.4.x-scala2.12",
"node_type_id": "i3.xlarge",
"autoscale": {
"min_workers": 1,
"max_workers": 4
},
"autotermination_minutes": 60,
"data_security_mode": "USER_ISOLATION"
}For a dedicated cluster, set data_security_mode to SINGLE_USER and name the owner in single_user_name. The owner is a user, or a group in recent releases.
{
"cluster_name": "ml-dev",
"spark_version": "15.4.x-scala2.12",
"node_type_id": "i3.xlarge",
"num_workers": 2,
"autotermination_minutes": 60,
"data_security_mode": "SINGLE_USER",
"single_user_name": "[email protected]"
}The node type shown is an AWS example. It differs on Azure and GCP.
Common errors
- Table not found or permission denied on a table you can see in Catalog Explorer. The cluster is probably in no isolation mode, which cannot reach UC data. Switch to standard or dedicated mode.
- A library or language feature is blocked on a shared cluster. Standard mode restricts some operations to keep users isolated. Use a dedicated cluster, or a supported alternative.
- Another person cannot attach to your cluster. Dedicated clusters accept only their assigned user or group. Share a standard cluster instead.
- Unexpected permissions on a dedicated cluster. Code on a dedicated cluster runs as the assigned identity. When the assignee is a group, check the group's grants as well as your own.
Exercise
A team of five analysts runs SQL and Python against Unity Catalog tables and wants one shared cluster where each person sees only the tables they have been granted. Which data_security_mode should the cluster use, and why would NONE fail?
Show answer
Use USER_ISOLATION (standard mode). It isolates users from each other and enforces Unity Catalog permissions on every query. NONE provides no isolation between users and cannot access Unity Catalog data, so the queries would fail.
Exercise
A data scientist needs an R library that standard mode does not support, and only she will use the cluster. Which mode and which extra field should you set?
Show answer
Set data_security_mode to SINGLE_USER (dedicated mode) and set single_user_name to her user name.