Sub topic 7
Ownership and delegated management
Every securable object in Unity Catalog has exactly one owner. Ownership is the strongest form of access on a single object, and it decides who can hand out access to everyone else. This chapter covers what an owner can do, how the MANAGE privilege delegates part of that power, how to transfer ownership, and the mistakes that cause trouble later.
Prerequisites
This chapter assumes you have read the earlier chapters in this tutorial, or already know the following:
- The Unity Catalog hierarchy: metastore, catalog, schema, and objects such as tables, views, volumes and functions.
- How
GRANT,REVOKEandSHOW GRANTSwork. - How privileges are inherited down the hierarchy.
- The difference between users, service principals and groups.
What ownership means
An object's owner is a single principal. That principal can be a user, a service principal or a group. When you create an object, you become its owner by default. If a job running as a service principal creates a table, the service principal owns it.
An owner can do the following on the object it owns:
- Grant and revoke privileges on it to other principals.
- Rename, alter or drop it.
- Transfer ownership to another principal.
- Use it, for example read a table, without any separate
SELECTgrant.
The last point is easy to miss. Ownership gives the owner the object's privileges, but it does not give automatic access to other objects. An owner of a schema does not automatically own the tables other people created inside it. It does, however, let the schema owner grant privileges on the schema, and those grants are inherited by the tables below it.
Ownership also does not cascade upward. Owning a table does not let you grant USE SCHEMA on its parent schema. A table owner who lacks USE CATALOG and USE SCHEMA on the parents cannot even reach the table by name.
Ownership and inheritance together
Ownership at a higher level gives a form of control over everything beneath it, because the owner can grant privileges there and those are inherited. The diagram shows who can manage what in a typical setup.
In practice, this means a catalog owner can control access to every schema and table in the catalog, even tables created by others. Choose catalog owners carefully.
Transferring ownership
Use ALTER ... OWNER TO to change an owner. The new owner can be a user, a service principal or a group, written with backticks if the name contains special characters.
ALTER TABLE main.sales.orders OWNER TO `data-engineers`;The same pattern works for other object types:
ALTER SCHEMA main.sales OWNER TO `data-engineers`;
ALTER CATALOG main OWNER TO `data-platform`;You can transfer ownership if you are the current owner, if you hold MANAGE on the object, or if you are a metastore admin. When you transfer ownership, the previous owner loses the implicit rights that came with ownership. Any explicit grants you made earlier to other principals stay in place.
To see who owns an object, describe it:
DESCRIBE TABLE EXTENDED main.sales.orders;The output includes an Owner row in the detailed table information. For catalogs and schemas, use DESCRIBE CATALOG EXTENDED main and DESCRIBE SCHEMA EXTENDED main.sales.
Why a group should own objects
If a person owns a table and then leaves the company, or changes teams, nobody else has the right to manage the table. An administrator has to step in and reassign it. If a group owns it, membership changes are handled in your identity provider and the table's management stays the same.
Use these rules of thumb:
- Give production objects to a group, not to an individual.
- Give objects created by automated jobs to a service principal or a group, not to the person who happened to launch the job.
- Keep the group small enough that membership means something. An owner group with 300 members is effectively public.
The MANAGE privilege
Sometimes you want someone to administer an object's access without making them the owner. The MANAGE privilege does this. A principal with MANAGE on an object can:
- Grant and revoke privileges on the object to others.
- Transfer ownership of the object.
- Drop or rename the object.
MANAGE does not by itself let the principal read data. To query a table, a principal with MANAGE still needs SELECT. However, a principal with MANAGE can grant SELECT to themselves, so you should treat MANAGE as close to full control and give it only to principals you would trust with read access.
GRANT MANAGE ON SCHEMA main.sales TO `sales-data-stewards`;Because of inheritance, MANAGE on a schema applies to the tables and views in it, and MANAGE on a catalog applies to everything in the catalog. That makes it a useful way to delegate. A central team owns the catalog, and each domain's stewards get MANAGE on their own schema.
| Capability | Owner | Holder of `MANAGE` | Holder of `SELECT` only |
|---|---|---|---|
| Read the data | Yes | Only after granting themselves `SELECT` | Yes |
| Grant and revoke privileges on the object | Yes | Yes | No |
| Transfer ownership | Yes | Yes | No |
| Drop the object | Yes | Yes | No |
| Counted as the single owner | Yes | No | No |
Granting privileges you do not hold
A principal can grant a privilege on an object only if they are the owner, hold MANAGE, or are an administrator with the right scope. Holding SELECT alone is not enough to pass SELECT on to others. Unity Catalog does not have a "grant option" like some other databases. Delegation is done through MANAGE.
A delegation pattern
A common layout splits responsibilities in three layers:
- A platform group owns the catalog. It creates schemas and sets baseline grants.
- A domain group owns each schema, or holds
MANAGEon it. It creates tables and decides who in the business can read them. - Consumer groups receive
USE CATALOG,USE SCHEMAandSELECTthrough the grants above.
The following script sets up that pattern for a sales domain.
CREATE CATALOG IF NOT EXISTS main;
ALTER CATALOG main OWNER TO `data-platform`;
CREATE SCHEMA IF NOT EXISTS main.sales;
ALTER SCHEMA main.sales OWNER TO `data-platform`;
-- Domain stewards administer the schema without owning the catalog.
GRANT MANAGE ON SCHEMA main.sales TO `sales-data-stewards`;
GRANT USE SCHEMA, CREATE TABLE ON SCHEMA main.sales TO `data-engineers`;
-- Consumers get read access, granted by the stewards later.
GRANT USE CATALOG ON CATALOG main TO `data-analysts`;Run this as a metastore admin or as a principal who can create catalogs. After it runs, the stewards can grant USE SCHEMA and SELECT on main.sales to analysts without involving the platform team.
Common errors and edge cases
The creator becomes the owner by accident
A data engineer creates a table in an interactive notebook and is recorded as the owner. Months later, they move teams. The fix is to transfer ownership as part of your deployment process. For example, add an ALTER TABLE ... OWNER TO statement to the job that creates the table.
Ownership of views and derived objects
A view's owner needs SELECT on the tables the view reads. If the owner loses that access, the view stops working for every consumer, even those who have SELECT on the view. Consumers do not need access to the underlying tables, only to the view and its parents. This is why the owner of a view should be a stable group that keeps its source access.
Dropping and recreating an object
If you drop an object and create a new one with the same name, the new object has a new owner (whoever ran CREATE) and none of the old grants. Use CREATE OR REPLACE where it fits, because it keeps the object and its privileges. Check the behavior for each object type before relying on it.
Access through a group you do not see
When SHOW GRANTS shows no grant to you, you may still have access through ownership, through MANAGE, through group membership, or through inheritance from a parent. To investigate, check the owner of the object and of each parent, and list the groups you belong to.
SELECT current_user();
SELECT is_account_group_member('data-engineers');
DESCRIBE TABLE EXTENDED main.sales.orders;
SHOW GRANTS ON SCHEMA main.sales;Metastore admins can override ownership
Administrators can take over objects, which is covered in the next chapter on administrative roles. For now, remember that ownership is not a barrier against an admin.
Choosing between ownership and MANAGE
| Situation | Better choice |
|---|---|
| One team is responsible for an object end to end | Make the team's group the owner |
| A central team owns a catalog but domains control their own schemas | Central group owns the catalog, domain group gets `MANAGE` on the schema |
| A person needs to review and fix access temporarily | Grant `MANAGE`, then revoke it |
| An automated pipeline creates tables | Run it as a service principal, then transfer ownership to the team's group |
Exercise
A data analyst named Priya created the table main.sales.orders in a notebook, so she owns it. She is moving to another team. Name two steps you should take so that management of the table does not depend on her, and say which statement you would use for each.
Show answer
First, transfer ownership to a group, for example ALTER TABLE main.sales.orders OWNER TO data-engineers;. Second, if the domain stewards should be able to manage access without owning the table, grant them MANAGE on the schema with GRANT MANAGE ON SCHEMA main.sales TO sales-data-stewards;. You can then confirm the result with DESCRIBE TABLE EXTENDED main.sales.orders (the Owner row) and SHOW GRANTS ON SCHEMA main.sales.
Exercise
A group holds MANAGE on the schema main.sales but has no SELECT grant. Can its members read main.sales.orders? Explain.
Show answer
Not directly. MANAGE allows granting and revoking privileges and transferring ownership, but it does not grant read access. Members could run GRANT SELECT ON SCHEMA main.sales TO ... for themselves and then read the table, which is why MANAGE should be treated as close to full control.