Sub topic 4
Access modes and data governance with Unity Catalog
This chapter explains what a cluster's access mode is, how it decides whether Unity Catalog can enforce permissions, and how to pick one. It assumes you have read the earlier chapters on cluster anatomy and Databricks Runtime. It also assumes you know what a Unity Catalog metastore, catalog, and schema are, and that you can read JSON and basic SQL.
Why compute needs an access mode
Unity Catalog is the Databricks governance layer. It stores permissions for data objects, using the three-level name catalog.schema.table. It decides who may read or change each object.
Unity Catalog can only make that decision if the compute running the query is trustworthy. A cluster executes user code, such as Python, Scala, or SQL, on machines that the user can often reach. If two users share a cluster and nothing separates their code, one user could read the other's temporary credentials or skip permission checks. Governance would then be advisory only.
The access mode is the cluster setting that defines how user code is isolated and which identity Unity Catalog sees. In the API the field is called data_security_mode.
The access modes
Current Databricks documentation uses these names. The API value is in parentheses.
| Access mode | API value | Who can use it | Unity Catalog |
|---|---|---|---|
| Standard | `USER_ISOLATION` | Many users at once | Supported |
| Dedicated | `SINGLE_USER` | One assigned user or group | Supported |
| No isolation shared | `NONE` | Many users at once | Not supported |
Older workspaces and documentation use different labels. "Shared" refers to standard mode, and "single user" or "assigned" refers to dedicated mode. Legacy values such as LEGACY_TABLE_ACL and LEGACY_PASSTHROUGH exist for the pre-Unity Catalog model. Use them only to keep old workloads running, not for new work.
Standard access mode
Standard mode lets several people share one cluster. Databricks isolates each user's code from the others, and Unity Catalog checks every query against the permissions of the user who ran it.
This isolation has costs. The platform blocks some operations that could break isolation:
- Low-level APIs such as RDD operations are restricted.
- Libraries and init scripts may need to be on an allowlist set by an administrator.
- Language support is narrower. Python and SQL work, and Scala has limits that depend on the runtime version. R is not available.
- Machine learning runtimes have fewer features than they do on dedicated clusters.
Standard mode is the usual default for shared interactive work because it combines sharing with governance.
Dedicated access mode
A dedicated cluster is tied to one principal. That principal is either a single user or a group. Queries on the cluster run with that identity's permissions.
Dedicated mode places few limits on code. It supports all languages, RDD APIs, the ML runtime, and custom libraries. The trade-off is that you cannot safely give the cluster to several unrelated users. Fine-grained controls such as row filters, column masks, and dynamic views need extra handling on dedicated compute. On recent runtimes, Databricks can route those queries through serverless filtering. Check the documentation for the runtime version and workspace features you use.
Job clusters use dedicated mode in practice, with the job's run-as identity as the principal. This is how a scheduled job runs as a service principal and not as whoever created it.
No isolation shared
This legacy mode does not isolate users and does not support Unity Catalog. Any Unity Catalog table reference fails. It is still useful for workloads that only touch data through paths and storage credentials outside Unity Catalog, but you should treat it as a migration target, not a choice for new work.
How a query is checked
When you run a query, Unity Catalog checks the identity the compute reports against the grants on each object. The check covers the whole path to the table.
- The user needs
USE CATALOGon the catalog. - The user needs
USE SCHEMAon the schema. - The user needs
SELECT(to read) orMODIFY(to write) on the table.
Missing any one of these fails the query, even if the others are granted.
GRANT USE CATALOG ON CATALOG main TO `data-analysts`;
GRANT USE SCHEMA ON SCHEMA main.sales TO `data-analysts`;
GRANT SELECT ON TABLE main.sales.orders TO `data-analysts`;Grant to groups, not to individual users, so that access changes when group membership changes. The backticks are required because the group name contains a hyphen.
To confirm which identity your compute is using, run this in a notebook:
display(spark.sql("SELECT current_user() AS me"))On a standard cluster, me is the person running the notebook. On a dedicated cluster assigned to a user, it is that user. In a job, it is the run-as identity.
Choosing a mode
The decision follows from who uses the cluster and what the code needs.
A few practical rules follow from the flow:
- Use standard mode for shared team clusters and for analysts who mostly write SQL and DataFrame code.
- Use dedicated mode for a data scientist who needs the ML runtime or unrestricted libraries on their own cluster.
- Use dedicated mode for jobs that run as a service principal, so the audit log shows that principal.
- Assign a dedicated cluster to a group when a small team shares it, so permissions stay tied to the group.
Setting the mode in the Clusters API
The access mode is set at creation time. The request below creates a standard cluster for a team. It matches the all-purpose example from earlier chapters.
{
"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"
}The node type is an AWS example. Azure and GCP use different node type names.
To create a dedicated cluster for one person, change the mode and name the principal in single_user_name. For a service principal, use its application ID. The request below is a complete example.
{
"cluster_name": "ana-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]"
}Common errors
These are the problems you are most likely to meet.
- A Unity Catalog table is not found or not accessible. The cluster is in
NONEmode or a legacy mode. Recreate it withUSER_ISOLATIONorSINGLE_USER. - "Permission denied" on a table you can see in the catalog browser. You have
SELECTon the table but lackUSE CATALOGorUSE SCHEMAon a parent. - A library fails to load on a standard cluster. The library is not on the allowlist. Ask an administrator to add it, or move the work to a dedicated cluster.
- A job reads data the creator can read but the run-as principal cannot. Grants apply to the identity that runs the job. Grant the service principal the three privileges listed earlier.
- A user cannot attach to a dedicated cluster. Only the assigned user or group members, and users with the
CAN ATTACH TOpermission on the cluster, can use it. Note that cluster permissions control who can use the cluster. Unity Catalog grants control which data it can read. They are separate systems.
Access mode and the other compute types
Access mode applies to classic compute, meaning clusters you configure with node types and worker counts. Serverless compute does not expose the setting. Databricks manages the isolation model for you, and Unity Catalog is always in force. That is one reason serverless is simple to govern. Chapter 7 covers serverless in detail.
Exercise
A team of six analysts shares one all-purpose cluster. They write SQL and PySpark against tables in Unity Catalog, and each person must see only the data they are granted. Which access mode should the cluster use, and which data_security_mode value goes in the API request?
Show answer
Standard access mode, set as "data_security_mode": "USER_ISOLATION". It lets several users share the cluster while Unity Catalog checks each query against the permissions of the user who ran it.
Exercise
A user has SELECT on main.sales.orders but the query fails with a permission error. Which two other privileges should you check, and on which objects?
Show answer
Check USE CATALOG on the main catalog and USE SCHEMA on the main.sales schema. Unity Catalog needs all three privileges along the path to the table.
Exercise
You need a cluster for one data scientist who uses the ML runtime and custom libraries and will read Unity Catalog tables. Write the two fields you set in the Clusters API request to make it a dedicated cluster for [email protected].
Show answer
Set "data_security_mode": "SINGLE_USER" and "single_user_name": "[email protected]".