Sub topic 2
The object hierarchy and securable objects
This chapter assumes you can write basic SQL, can open the Databricks SQL editor or a notebook, and know what role-based access control means. You do not need to know any Unity Catalog privilege names yet. Later chapters cover those.
Why the hierarchy matters
Every permission decision in Unity Catalog is made against a securable object. A securable object is anything you can grant access to. Before you can reason about who may do what, you need to know which objects exist and how they nest. The nesting decides where you grant a privilege and how far it reaches.
Unity Catalog uses a three-level namespace for data: catalog, schema, and then the object itself. You write it as catalog.schema.object. Above those sits the metastore. Some securable objects live outside this namespace, such as storage credentials and external locations.
The levels of the hierarchy
The main levels are these:
- Metastore. The top-level container for metadata and permissions. A metastore is attached to one or more workspaces in a region. Account-level objects, such as storage credentials and external locations, are registered here.
- Catalog. The first level of the three-level namespace. Teams commonly use catalogs to separate environments (
dev,prod) or business domains. - Schema. The second level, also called a database. A schema groups related tables, views, volumes, functions, and models.
- Objects inside a schema. Tables, views, volumes, functions, and registered models.
The arrow from a storage credential to an external location shows a dependency. An external location pairs a cloud storage path with a storage credential. Chapter nine covers that in detail.
Securable objects in detail
Each kind of object has a different role. Knowing what each one is for helps you pick the right level for a grant.
| Securable object | Lives in | What it represents |
|---|---|---|
| Catalog | Metastore | Top-level grouping of schemas |
| Schema | Catalog | Grouping of tables, views, volumes, functions, and models |
| Table | Schema | Structured data, either managed or external |
| View | Schema | A saved query over other tables or views |
| Volume | Schema | A governed location for files that are not tables |
| Function | Schema | A user-defined function, also used for row filters and column masks |
| Registered model | Schema | A machine learning model and its versions |
| Storage credential | Metastore | A cloud identity that lets Unity Catalog reach storage |
| External location | Metastore | A storage path tied to a storage credential |
Tables: managed and external
A managed table stores its data in a location Unity Catalog controls. Dropping the table also removes the underlying data after a retention period. An external table points at data in a path you control through an external location. Dropping an external table removes only the metadata. The data files stay in cloud storage.
This difference matters for permissions. For a managed table, Unity Catalog is the only intended path to the data. For an external table, the files also exist in cloud storage, so you must also decide who can reach that storage path directly.
Views
A view is a saved query. Querying a view requires access to the view itself. In the standard model, the view owner needs access to the underlying tables, and the person querying the view does not. This lets you expose a safe subset of a table without granting access to the table. Dynamic views build on this idea and are covered in a later chapter.
Volumes
A volume governs access to files, such as CSV files, images, or model artifacts, that do not belong in a table. Volumes can also be managed or external. You reference files with a path of the form /Volumes/catalog/schema/volume/path/to/file.
Functions and models
A function is a user-defined function stored in a schema. You can grant EXECUTE on it, and you also use functions to implement row filters and column masks. A registered model is a machine learning model with versioned artifacts, and you grant access to it the same way as to other schema-level objects.
Inspecting the hierarchy with SQL
You can walk the hierarchy with ordinary commands. Each command works one level down from the last.
SHOW CATALOGS;
SHOW SCHEMAS IN main;
SHOW TABLES IN main.sales;
SHOW VOLUMES IN main.sales;
SHOW FUNCTIONS IN main.sales;These commands return only objects you are allowed to see. If a catalog is missing from SHOW CATALOGS, you may lack privileges on it, or it may be bound to a different workspace. The object can exist and still be invisible to you.
You can also check which catalog and schema your session uses by default. Fully qualified names avoid ambiguity.
SELECT current_catalog(), current_schema();How the hierarchy shapes access
The hierarchy has three effects on permissions.
Parent access is required
To use an object, you need access to the objects above it. To query main.sales.orders, a principal needs USE CATALOG on main, USE SCHEMA on main.sales, and SELECT on the table. Without the first two, the SELECT grant has no effect. This is the most common cause of "I was granted SELECT but still get an error."
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`;Grants flow downward
A privilege granted on a container applies to the objects inside it, including objects created later. If you grant SELECT on a schema, the principal can read every current and future table and view in that schema. Granting at a higher level is less work but gives wider access. Chapter six covers inheritance fully.
Ownership attaches to each object
Every securable object has exactly one owner. The owner can grant privileges on that object and manage it. The user who creates an object becomes its owner by default. Ownership is a property of the individual object, so owning a catalog does not make you the owner of the schemas inside it, although the owner of a catalog can manage objects in it through inheritance of the management right.
Three-level names and the legacy namespace
Workspaces created before Unity Catalog may have a hive_metastore catalog. It holds tables from the legacy workspace-local Hive metastore. It appears next to Unity Catalog catalogs in the same three-level naming, but it is not governed by Unity Catalog privileges in the same way. Treat it as a separate system that happens to be visible in the same namespace. Migrating tables into a Unity Catalog catalog is what brings them under the permission model described in this tutorial.
Common errors
- Granting only
SELECTon a table. The query fails because the principal lacksUSE CATALOGorUSE SCHEMAon a parent. Grant the parent privileges too. - Granting at the wrong level. A grant on a single table does not cover new tables. A grant on a schema covers all of them. Choose the level that matches the intent.
- Confusing a view with its sources. Access to a view does not grant access to the source tables for direct queries. Grant each separately if both are needed.
- Assuming an external table is protected by table privileges alone. The files remain in cloud storage. Control who can reach the path through external locations and cloud permissions.
- Using a name without its catalog. An unqualified name resolves against the session defaults, which can differ between notebooks, jobs, and the SQL editor. Use fully qualified names in shared code.
Summary
Unity Catalog organizes data and AI assets as metastore, catalog, schema, and schema-level objects, with storage credentials and external locations attached to the metastore. Access to any object requires access to its parents. Privileges granted on a container flow to what it holds, and each object has a single owner. With this map in place, the next chapters can cover who receives access and which privileges they receive.
Exercise
A user in the group data-analysts has been granted SELECT on main.sales.orders and gets a permission error when running SELECT * FROM main.sales.orders. No other grants exist for the group. Which privileges are missing, and on which objects?
Show answer
The group needs USE CATALOG on the catalog main and USE SCHEMA on the schema main.sales. SELECT on the table is not enough, because access to an object also requires access to its parent catalog and schema.
Exercise
You grant SELECT on the schema main.sales to a group. Next week a teammate creates the table main.sales.returns. Can the group read it, and why?
Show answer
Yes. A privilege granted on a schema is inherited by the tables and views in it, including ones created later, so the group can read main.sales.returns as long as it also has USE CATALOG on main and USE SCHEMA on main.sales.
Exercise
Why do a managed table and an external table need different thinking about access control?
Show answer
A managed table keeps its data in a location Unity Catalog controls, so table privileges are the intended access path. An external table's files sit in a cloud storage path you control, so you must also govern who can reach that path, using external locations and cloud permissions, in addition to table privileges.