Sub topic 6
How privileges are inherited down the hierarchy
This chapter assumes you know the Unity Catalog object hierarchy (metastore, catalog, schema, and the tables, views, volumes and functions inside a schema). It also assumes you can run GRANT, REVOKE and SHOW GRANTS. Here you will learn how a single grant can apply to many objects at once, and how to predict a user's effective access.
The inheritance rule
In Unity Catalog, a privilege granted on a container object is inherited by the objects inside it. The containers are the metastore, catalogs and schemas. If you grant SELECT on a schema, the principal can read every current table and view in that schema. The same grant also covers any table or view created in the schema later.
Inheritance flows only downward. A grant on a table never affects its schema or catalog.
Granting at the schema level
This example grants SELECT on a schema, then removes it at the same level.
GRANT SELECT ON SCHEMA main.sales TO `data-analysts`;
REVOKE SELECT ON SCHEMA main.sales FROM `data-analysts`;After the first statement, members of data-analysts can query every table and view in main.sales, including ones created tomorrow. After the REVOKE, that inherited access is gone.
Inheritance does not replace USE privileges
Inheritance and the USE CATALOG and USE SCHEMA privileges are separate mechanisms. Reading a table needs both:
USE CATALOGon the parent catalog.USE SCHEMAon the parent schema.SELECTon the table, either granted directly or inherited.
This is the most common source of confusion. A user with SELECT on a catalog still cannot query a table until they also hold USE CATALOG and USE SCHEMA on the right parents. Those two privileges can also be inherited. A USE SCHEMA granted at catalog level applies to every schema in the catalog.
-- Grants at catalog level: one statement each, inherited by all schemas and tables below
GRANT USE CATALOG ON CATALOG main TO `data-analysts`;
GRANT USE SCHEMA ON CATALOG main TO `data-analysts`;
GRANT SELECT ON CATALOG main TO `data-analysts`;With these three statements, data-analysts can read every table and view in every schema of main. That is convenient and also broad, so use it deliberately.
Which privileges are inherited
Most privileges are inherited. Some examples:
| Privilege granted on | Inherited by | Effect |
|---|---|---|
| Catalog: `SELECT` | All schemas, tables and views in the catalog | Read all data in the catalog |
| Catalog: `USE SCHEMA` | All schemas in the catalog | Browse into every schema |
| Schema: `SELECT` | Tables and views in the schema | Read all tables in the schema |
| Schema: `MODIFY` | Tables in the schema | Insert, update and delete rows in every table |
| Schema: `CREATE TABLE` | Applies to the schema itself | Create new tables in that schema |
| Schema: `READ VOLUME` | Volumes in the schema | Read files in every volume |
| Schema: `EXECUTE` | Functions in the schema | Call every function |
CREATE privileges such as CREATE TABLE are granted on the container where the new object will live. They do not describe access to existing children. Check the privilege reference for your workspace to confirm which securable types each privilege applies to.
Inheritance is additive
Privileges are additive. A principal's effective access is the union of everything granted to them directly and through every group they belong to, at every level of the hierarchy. There is no explicit "deny" in Unity Catalog grants.
This has two consequences.
- You cannot grant
SELECTon a schema and then carve out one table by revoking it on that table. AREVOKEon the table removes only a grant made on the table itself. The inherited grant from the schema still applies. - Removing access means removing it where it was granted, from every group and level that provides it.
GRANT SELECT ON SCHEMA main.sales TO `data-analysts`;
-- This does NOT block data-analysts from reading orders.
-- No grant exists on the table itself, so there is nothing to remove,
-- and the schema-level grant still applies.
REVOKE SELECT ON TABLE main.sales.orders FROM `data-analysts`;If one table must stay hidden, do not grant on the whole schema. Grant SELECT on individual tables, or move the sensitive table to a separate schema. Row filters and column masks, covered in a later chapter, can also limit what a broadly granted principal sees.
Finding where access comes from
SHOW GRANTS shows the privileges set directly on an object. Inherited privileges are shown with the object they were granted on, so you can trace them to their source. Run it at each level of the path when you debug a "permission denied" error.
SHOW GRANTS ON TABLE main.sales.orders;
SHOW GRANTS ON SCHEMA main.sales;
SHOW GRANTS ON CATALOG main;
SHOW GRANTS `data-analysts` ON SCHEMA main.sales;A practical debugging order:
- Check
USE CATALOGon the catalog for the user or any of their groups. - Check
USE SCHEMAon the schema, or on the catalog if inherited. - Check
SELECTon the table, then on the schema, then on the catalog. - Check whether the table is a view, since views need extra care (see below).
Views and inherited privileges
A schema-level SELECT covers views in the schema. A view is also a query over other tables, and the rules for the underlying tables depend on who owns the view.
- The view owner needs
SELECTon the underlying tables, plusUSE CATALOGandUSE SCHEMAon their parents. - Other users need
SELECTon the view andUSEprivileges on the view's catalog and schema. They do not need access to the underlying tables.
This lets you expose a restricted slice of a table without granting access to the table itself. Granting SELECT on the schema that holds only views, and keeping base tables in a different schema, is a common pattern.
Ownership interacts with inheritance
The owner of an object can manage grants on it. Ownership of a container is also inherited in a limited sense: the owner of a catalog or schema can manage privileges on objects inside it. So an owner can grant access to any child object without owning that child.
ALTER TABLE main.sales.orders OWNER TO `data-engineers`;Assign ownership to a group, not a person, so management does not depend on one user. The next chapter covers ownership in detail.
Edge cases and common errors
- New objects are covered automatically. A schema-level
SELECTapplies to tables created after the grant. Review broad grants periodically, because they can expose data nobody planned for. - Dropping and recreating a table. Grants made directly on the table are removed with it. Inherited grants continue to apply to the new table with the same name.
- Metastore-level grants. A privilege granted on the metastore is inherited by every catalog. Use this only for platform-wide roles, because it is the broadest scope you can create.
- Permission denied despite a grant. The most frequent cause is a missing
USE CATALOGorUSE SCHEMA. The second is a grant to a group the user is not in. - Revoke has no effect. You revoked at a lower level than the grant. Run
SHOW GRANTSat the higher levels and revoke there. - Too much access after a revoke. The user belongs to a second group that carries the same privilege.
Choosing the level for a grant
| Level | Use when | Risk |
|---|---|---|
| Catalog | A team owns or reads a whole domain, such as everything in `finance` | Covers all future schemas and tables |
| Schema | A team works with one subject area | Covers all future tables in that schema |
| Table or view | A few objects need exact control | More statements to maintain |
A good default is to grant read access at schema level, group sensitive objects into their own schemas, and use table-level grants only for exceptions.
Exercise
A group analysts has USE CATALOG on main, USE SCHEMA on main.sales, and SELECT on the schema main.sales. You run REVOKE SELECT ON TABLE main.sales.orders FROM analysts, and the analysts can still query orders. Why, and what should you do to hide only that table?
Show answer
The SELECT grant lives on the schema, and the table inherits it. Revoking on the table removes only a grant made on the table, and none exists, so nothing changes. Unity Catalog has no deny. To hide orders, revoke SELECT on the schema, then grant SELECT on each table the analysts should read. Alternatively, move orders to a different schema that the group has no grant on.
Exercise
A user belongs to data-analysts, which has SELECT on the catalog main. They get "permission denied" when they query main.sales.orders. Which two privileges should you check for first, and where can each be granted?
Show answer
Check USE CATALOG on main and USE SCHEMA on main.sales. USE CATALOG is granted on the catalog (or the metastore). USE SCHEMA can be granted on the schema itself or on the catalog, where it is inherited by every schema. SELECT alone does not let a user reach the table.