Sub topic 11
How privileges are inherited
This chapter assumes you can run basic SQL in a Databricks notebook or the SQL editor. It also assumes you know that Unity Catalog names objects as catalog.schema.table, and that you have seen GRANT and REVOKE in the previous chapter. Here you will learn how a single grant can reach many objects, what it cannot do, and how to check what a principal can actually do.
The inheritance rule
Unity Catalog objects form a hierarchy: the metastore contains catalogs, catalogs contain schemas, and schemas contain tables, views, volumes, and functions. A privilege granted on a container object is inherited by the objects below it. This includes objects created after the grant.
For example, SELECT granted on a schema applies to every table and view in that schema, now and in the future. SELECT granted on a catalog applies to every table and view in every schema in that catalog.
In the diagram, the grant on dev reaches orders, raw_orders, and campaigns. The grant on dev.sales reaches only orders and raw_orders.
Access needs the whole path
Inheritance passes privileges down. It does not remove the need for access to the parent objects. To read a table, a principal needs all of these:
USE CATALOGon the table's catalog.USE SCHEMAon the table's schema.SELECTon the table, either granted directly or inherited from the schema or catalog.
USE CATALOG and USE SCHEMA let a principal reach into an object. They do not let it read data. If you grant SELECT on a table but not the two USE privileges, queries fail.
The following grants give a group read access to one table:
GRANT USE CATALOG ON CATALOG dev TO `data-analysts`;
GRANT USE SCHEMA ON SCHEMA dev.sales TO `data-analysts`;
GRANT SELECT ON TABLE dev.sales.orders TO `data-analysts`;This is the narrowest way to share one table. The group sees only that table inside dev.sales.
Granting at the schema level
If the group should read everything in the schema, grant SELECT once on the schema:
GRANT SELECT ON SCHEMA dev.sales TO `data-analysts`;
SHOW GRANTS ON SCHEMA dev.sales;SHOW GRANTS ON SCHEMA lists the grant on the schema itself. A table created tomorrow in dev.sales is readable by data-analysts without another statement, because the privilege is inherited.
Revoking works at the same level where the grant was made:
REVOKE SELECT ON SCHEMA dev.sales FROM `data-analysts`;After this statement, the group loses the inherited SELECT on every table in the schema. A direct grant on an individual table, if one exists, stays in place.
Inheritance is additive
Unity Catalog has no deny rule. A principal's effective access is the union of everything granted to it: grants made directly, grants inherited from parent objects, and grants given to any group it belongs to. You cannot grant SELECT on a schema and then block one table inside it.
This has a practical consequence for layout. If one table in a schema needs tighter access than the others, put it in a separate schema. Do not expect to carve out an exception.
| Situation | Result |
|---|---|
| `SELECT` on schema, nothing on tables | Principal reads every table in the schema, including new ones. |
| `SELECT` on one table, nothing on schema | Principal reads only that table, given the `USE` privileges. |
| `SELECT` on schema, then `REVOKE` on one table | Nothing changes. The schema grant still applies. |
| `SELECT` on schema, `REVOKE` on schema | Access is gone unless granted another way, such as through a group. |
| `SELECT` on catalog | Principal reads tables in every schema of the catalog. |
Groups and effective access
Principals are users, service principals, and groups. A grant to a group applies to every member. A user who belongs to two groups gets the union of both groups' privileges, plus anything granted to the user directly.
This is why a revoke can look like it did nothing. The user may still hold the privilege through another group or another level. To find the cause, look at grants at each level of the hierarchy.
Which privileges are inherited
Most data privileges are inherited when granted on a container. These include SELECT and MODIFY (for tables and views), READ VOLUME and WRITE VOLUME (for volumes), EXECUTE (for functions), and the CREATE privileges such as CREATE TABLE on a schema.
USE CATALOG and USE SCHEMA are also inherited in a limited way. Granting USE SCHEMA on a catalog gives the principal USE SCHEMA on every schema in it. Granting USE CATALOG on the metastore is not how access to a catalog works, so grant it on the catalog.
Ownership is a separate path. The owner of an object holds all privileges on it, and the owner of a container can manage the objects inside it. The owner of a catalog can grant privileges on any object in that catalog. See the chapter on principals and ownership for details.
Granting broadly with care
A grant on a catalog is powerful. The statement below gives data-analysts read access to every table and view in dev:
GRANT USE CATALOG ON CATALOG dev TO `data-analysts`;
GRANT USE SCHEMA ON CATALOG dev TO `data-analysts`;
GRANT SELECT ON CATALOG dev TO `data-analysts`;This is convenient in a development catalog where everything is meant to be shared. In a catalog that holds sensitive data, it is usually too wide, because every future schema is included automatically.
A reasonable rule: grant at the highest level where the audience matches. If every object at that level should be visible to the group, grant there. If not, move down one level.
Checking what a principal can do
SHOW GRANTS shows grants made on a specific object. By default it lists the grants on that object, and it can include grants inherited from the parents. To investigate, run it at each level:
SHOW GRANTS ON CATALOG dev;
SHOW GRANTS ON SCHEMA dev.sales;
SHOW GRANTS ON TABLE dev.sales.orders;You can also filter by principal:
SHOW GRANTS `data-analysts` ON SCHEMA dev.sales;When a user reports "permission denied", work through this order:
- Confirm which groups the user belongs to.
- Check
USE CATALOGon the catalog. - Check
USE SCHEMAon the schema. - Check
SELECTon the table, the schema, and the catalog. - Confirm the object name. A typo in the schema name produces a not-found error that can look like a permission problem.
Common errors
- Granting
SELECTon a table but forgettingUSE CATALOGorUSE SCHEMA. The query fails even though the table grant exists. - Revoking on the wrong level and assuming access is gone. Check the parent levels and group membership.
- Granting at catalog level in a shared catalog and exposing future schemas without a review.
- Expecting a deny. Unity Catalog only adds privileges, so exceptions require a separate schema or catalog.
- Granting to an individual user instead of a group. Individual grants are hard to audit and are easy to forget when people change roles.
Exercise
The group finance has USE CATALOG on prod and USE SCHEMA on prod.billing. You run GRANT SELECT ON SCHEMA prod.billing TO finance. Next week someone creates prod.billing.refunds. Can finance query it? Then you run REVOKE SELECT ON TABLE prod.billing.refunds FROM finance. Can finance still query it?
Show answer
Yes to the first question, because SELECT granted on the schema is inherited by tables created later. Yes to the second as well. The revoke targets a table-level grant that does not exist, and the schema-level grant still applies. To remove access you must revoke SELECT on the schema, or move refunds into a different schema that finance cannot read.
Exercise
A user is in groups analysts and interns. SELECT on dev.sales was granted to analysts and then revoked from interns. The user can still read tables in dev.sales. Why?
Show answer
Privileges are additive. The user holds the privilege through analysts, and revoking it from interns removes only the grant to that group. To remove access, revoke from analysts or remove the user from that group.