Sub topic 13
Permissions and governance across layers
This chapter assumes you know the bronze, silver, and gold layout from the earlier chapters. It also assumes you can read basic SQL GRANT statements. The layers are only useful if the right people and jobs can reach the right tables. This chapter shows how to map each layer to a Unity Catalog permission set.
Why governance follows the layers
Each layer holds data of a different quality and sensitivity.
- Bronze holds raw records exactly as received. It can contain malformed rows, duplicates, and personal data you have not yet masked.
- Silver holds cleaned, typed data. It is still detailed and often still contains personal data.
- Gold holds aggregates shaped for a business purpose. It is usually the safest layer to share widely.
Permissions should get broader as you move toward gold. A dashboard user who can read main.bronze.orders can see every raw field, including values you meant to filter or mask later. Least privilege means giving each principal only the layers its work needs.
A principal in Unity Catalog is a user, a group, or a service principal. A service principal is an identity for automation, such as a scheduled job. Grant privileges to groups and service principals, not to individual users. When someone joins or leaves a team, you change group membership and leave the grants alone.
How Unity Catalog checks access
Unity Catalog has a three-level namespace: catalog, schema, and table. A principal needs a privilege at each level to reach a table.
| Object | Privilege | What it allows |
|---|---|---|
| Catalog | `USE CATALOG` | Look inside the catalog |
| Schema | `USE SCHEMA` | Look inside the schema |
| Table or view | `SELECT` | Read rows |
| Table | `MODIFY` | Insert, update, delete, and merge |
| Schema | `CREATE TABLE` | Create new tables in the schema |
| Volume | `READ VOLUME` | Read files, such as the landing zone |
| Volume | `WRITE VOLUME` | Write files, such as checkpoints |
Privileges are inherited downward. If you grant SELECT on a schema, the principal can read every current and future table in that schema. If you grant SELECT on a catalog, it applies to every schema in the catalog.
This is why the layout from the Unity Catalog chapter matters. With one catalog main and schemas bronze, silver, and gold, you can grant at the schema level and each grant stays tied to one layer.
Who gets what
A typical assignment looks like this.
| Principal | Bronze | Silver | Gold |
|---|---|---|---|
| Pipeline service principal | Create, write, read | Create, write, read | Create, write |
| Data engineers | Read | Read | Read |
| Data scientists | None | Read | Read |
| Analysts and dashboards | None | None | Read |
The pipeline service principal writes every layer, so it needs MODIFY and CREATE TABLE on all three schemas. It also needs READ VOLUME on the landing volume and WRITE VOLUME on the checkpoint volume. Auto Loader reads files from the first and stores its progress in the second.
flowchart LRThe block above is not a valid diagram. Use the one below.
Granting permissions per layer
This script sets up the table above. Replace the service principal ID with the application ID shown on your service principal's page in the workspace. The groups data_engineers, data_scientists, and analysts must already exist at the account level.
-- Pipeline service principal: writes all layers
GRANT USE CATALOG ON CATALOG main TO `11111111-2222-3333-4444-555555555555`;
GRANT USE SCHEMA, CREATE TABLE, SELECT, MODIFY ON SCHEMA main.bronze TO `11111111-2222-3333-4444-555555555555`;
GRANT USE SCHEMA, CREATE TABLE, SELECT, MODIFY ON SCHEMA main.silver TO `11111111-2222-3333-4444-555555555555`;
GRANT USE SCHEMA, CREATE TABLE, SELECT, MODIFY ON SCHEMA main.gold TO `11111111-2222-3333-4444-555555555555`;
GRANT READ VOLUME ON VOLUME main.sales.landing TO `11111111-2222-3333-4444-555555555555`;
GRANT READ VOLUME, WRITE VOLUME ON VOLUME main.sales.checkpoints TO `11111111-2222-3333-4444-555555555555`;
-- Data engineers: read everywhere, for debugging
GRANT USE CATALOG ON CATALOG main TO `data_engineers`;
GRANT USE SCHEMA, SELECT ON SCHEMA main.bronze TO `data_engineers`;
GRANT USE SCHEMA, SELECT ON SCHEMA main.silver TO `data_engineers`;
GRANT USE SCHEMA, SELECT ON SCHEMA main.gold TO `data_engineers`;
-- Data scientists: cleaned data and marts
GRANT USE CATALOG ON CATALOG main TO `data_scientists`;
GRANT USE SCHEMA, SELECT ON SCHEMA main.silver TO `data_scientists`;
GRANT USE SCHEMA, SELECT ON SCHEMA main.gold TO `data_scientists`;
-- Analysts: gold only
GRANT USE CATALOG ON CATALOG main TO `analysts`;
GRANT USE SCHEMA, SELECT ON SCHEMA main.gold TO `analysts`;Check the result with SHOW GRANTS.
SHOW GRANTS ON SCHEMA main.gold;
SHOW GRANTS `analysts` ON SCHEMA main.silver;The second statement should return no rows. If it returns a SELECT grant, the privilege is coming from somewhere else, such as a grant on the catalog.
Ownership
Every object has an owner. The owner can grant privileges on the object and can drop it. If a developer creates main.gold.daily_revenue from a notebook under a personal account, that person owns the table. When they leave, the table has no active owner.
Make the pipeline service principal create and own the production tables. For existing objects, transfer ownership to a group or service principal.
ALTER SCHEMA main.gold OWNER TO `data_engineers`;Narrowing access inside a layer
Schema-level grants are coarse. Sometimes a silver table is shared widely but has a few sensitive columns or rows. Unity Catalog has three tools for this.
- A view exposes selected columns or rows. A user needs
SELECTon the view. The user does not need access to the underlying table, because the view runs with the owner's privileges on the source. - A column mask is a SQL function attached to a column. It returns the real value or a masked value depending on who is asking.
- A row filter is a SQL function attached to a table. It hides rows for users who should not see them.
This example masks email for everyone outside the pii_readers group.
CREATE OR REPLACE FUNCTION main.silver.mask_email(email STRING)
RETURNS STRING
RETURN CASE
WHEN is_account_group_member('pii_readers') THEN email
ELSE CONCAT('***@', SPLIT(email, '@')[1])
END;
ALTER TABLE main.silver.customers
ALTER COLUMN email SET MASK main.silver.mask_email;Mask personal data as early as silver if many people read that layer. Dropping or hashing the field before gold is simpler still, because the gold table then has nothing sensitive to protect.
Tags, lineage, and audit
Governance also means knowing what the data is and where it came from.
Tags label objects. A pii tag on a column lets you find every sensitive column with one search, and a layer tag on a table makes the intended layer explicit.
ALTER TABLE main.silver.customers SET TAGS ('layer' = 'silver');
ALTER TABLE main.silver.customers ALTER COLUMN email SET TAGS ('pii' = 'true');Lineage is captured automatically for queries and pipelines that run on Unity Catalog compute. The Lineage tab in Catalog Explorer shows which tables feed main.gold.daily_revenue. You can also query the system table.
SELECT DISTINCT source_table_full_name, target_table_full_name
FROM system.access.table_lineage
WHERE target_table_full_name = 'main.gold.daily_revenue';Lineage answers a common question: "If I change this bronze column, which gold tables break?" It also supports impact review when a source system reports bad data. System tables need to be enabled by an account admin, and you need SELECT on them.
Audit logs record who read or changed what. The system table system.access.audit holds those events. Review them when you investigate unexpected access to bronze or silver.
Common errors
USE CATALOGorUSE SCHEMAmissing.SELECTon a table fails even though you granted it. The principal also needs the twoUSEprivileges above it. This is the most frequent cause of "permission denied" on a table that looks correctly granted.- Grants too high in the hierarchy. A grant on a catalog or schema reaches objects created later. Check what your grants include after adding new tables.
- Personal ownership of production tables. Pipelines fail or tables become unmanageable when the owner leaves.
- Pipeline runs as a user. Jobs then break when that user's access changes. Run production jobs as a service principal.
- Volume permissions forgotten. Auto Loader fails to read the landing path or write its checkpoint. Table grants do not cover volumes.
- Sensitive data copied downstream. A mask on silver does not protect a gold table built from the unmasked column in a way that bypasses the mask. Review what each gold table selects.
Exercise
An analyst in the analysts group has SELECT on main.gold.daily_revenue but gets a permission error running SELECT * FROM main.gold.daily_revenue. Name two privileges to check, and explain why granting SELECT on the catalog main is not the right fix.
Show answer
Check USE CATALOG on main and USE SCHEMA on main.gold, because a table SELECT alone is not enough. Granting SELECT on the catalog would be inherited by every schema, so analysts could also read main.bronze and main.silver, breaking the layer-based least-privilege design.
Exercise
The pipeline's Auto Loader step fails with a permission error on /Volumes/main/sales/checkpoints/orders_bronze, although the service principal can write to main.bronze.orders. What privilege is likely missing?
Show answer
WRITE VOLUME (and READ VOLUME) on main.sales.checkpoints. Volume access is granted separately from table access, so the table grants do not cover the checkpoint path.