Sub topic 6
How privileges are inherited down the hierarchy
This chapter assumes you know the Unity Catalog object hierarchy (metastore, catalog, schema, table or view) and can run basic GRANT and REVOKE statements. It covers how a privilege granted on one object also applies to the objects below it, and the errors that follow from that.
The inheritance rule
When you grant a privilege on a container, the grantee gets that privilege on every current and future child object inside it. A grant on a catalog reaches all of its schemas and all of their tables, views, volumes and functions. A grant on a schema reaches the objects in that schema.
GRANT SELECT ON SCHEMA main.sales TO `data-analysts`;After this statement, members of data-analysts can read every table and view in main.sales. That includes tables created next month. You do not need to repeat the grant for each new table.
What inheritance does not do
Inheritance only flows downward. A grant on a table never gives access to its schema or catalog. This is why a table-level SELECT alone is not enough to query a table.
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`;The principal needs USE CATALOG and USE SCHEMA on the parents to reach the table. USE CATALOG and USE SCHEMA allow the principal to look inside the container. They do not allow reading any data.
Revoking and inspecting inherited privileges
You revoke an inherited privilege at the level where it was granted.
REVOKE SELECT ON SCHEMA main.sales FROM `data-analysts`;Running REVOKE SELECT ON TABLE main.sales.orders does not remove a schema-level grant. The table-level statement has nothing to remove, because the privilege was never granted on the table itself. The group keeps access through the schema.
To see what is granted where, run SHOW GRANTS on each level and compare the results.
SHOW GRANTS ON SCHEMA main.sales;
SHOW GRANTS ON TABLE main.sales.orders;Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Query fails even though the user has `SELECT` on the table | Missing `USE CATALOG` or `USE SCHEMA` on a parent | Grant the `USE` privileges on the parents |
| User can still read a table after you revoked it on the table | The privilege is also granted on the schema or catalog | Revoke at the level where it was granted |
| User can read tables you never meant to share | A broad grant on a catalog or schema | Grant at a narrower level |
| New tables are readable immediately | The grant is on the parent schema, so it covers future tables | Expected behavior. Grant on individual tables if you want to opt in per table |
Choosing the grant level
Granting on a schema is the usual choice. It keeps the number of grants small and covers new tables automatically. Granting on a catalog is convenient but gives wide access, so use it only when every schema in the catalog should be shared in the same way. Grant on a single table when only that table should be visible.
Exercise
A group holds SELECT on the schema main.sales, and you run REVOKE SELECT ON TABLE main.sales.orders FROM that group. Can the group still query main.sales.orders? Why?
Show answer
Yes. The privilege was granted on the schema, not on the table, so the table-level revoke removes nothing. The group still inherits SELECT from the schema. To remove access, revoke SELECT on the schema, then grant SELECT on the tables the group should still read.
Exercise
A user has SELECT on main.sales.orders but gets a permission error when querying it. Which two privileges are most likely missing, and on which objects?
Show answer
USE CATALOG on the catalog main and USE SCHEMA on the schema main.sales. Inheritance only flows down, so a table-level grant does not give access to the parents.