Sub topic 2
Catalogs and schemas: the namespace volumes live in
This chapter assumes you know the Databricks workspace and notebooks, basic SQL, and what cloud object storage is. It explains the naming structure that every volume sits inside, because that structure decides your file paths and your permissions.
The three-level namespace
Unity Catalog organizes data objects in three levels:
- A catalog is the top-level container. Teams often use one per environment or business unit.
- A schema (also called a database) groups related objects inside a catalog.
- An object sits inside a schema. Objects include tables, views, functions, models, and volumes.
You write a full name as catalog.schema.object. A volume is a third-level object, just like a table, so it follows the same rules.
The metastore above the catalog is the account-level container that holds all of this metadata. A workspace is attached to one metastore, and you rarely work with it directly.
Why the namespace matters for files
The namespace gives a volume two things.
- Its path. The volume
main.default.landingis reached at/Volumes/main/default/landing/. The three names appear in the same order, separated by slashes instead of dots. - Its permissions. Access is checked at each level. To use a file in a volume, a user needs access to the catalog, the schema, and the volume itself.
Working with catalogs and schemas
Every new workspace usually has a catalog (often main) with a default schema. You can use these to practice. To create your own, run:
CREATE CATALOG IF NOT EXISTS dev;
CREATE SCHEMA IF NOT EXISTS dev.raw_files
COMMENT 'Landing area for uploaded files';
USE CATALOG dev;
USE SCHEMA raw_files;
SELECT current_catalog(), current_schema();USE CATALOG and USE SCHEMA set defaults for the session. After that, you can write landing instead of dev.raw_files.landing. Fully qualified names are safer in shared notebooks and jobs, because they do not depend on session state.
Privileges at each level
To read or write a volume's files, a user typically needs all of these:
| Level | Privilege | What it allows |
|---|---|---|
| Catalog | USE CATALOG | See and enter the catalog |
| Schema | USE SCHEMA | See and enter the schema |
| Schema | CREATE VOLUME | Create new volumes in the schema |
| Volume | READ VOLUME / WRITE VOLUME | Read or write files in the volume |
Privileges flow downward. If you grant a privilege on a catalog or schema, it applies to the objects inside it. Granting READ VOLUME on a schema, for example, covers every volume in that schema. The volume-level privileges are covered in a later chapter.
Common errors
CATALOG_NOT_FOUNDorSCHEMA_NOT_FOUND. The name is misspelled, or it does not exist in the attached metastore. RunSHOW CATALOGSandSHOW SCHEMAS IN mainto check.- Permission denied on a volume you can see. You may be missing
USE CATALOGorUSE SCHEMAon a parent. A volume privilege alone is not enough. - A path that works in one notebook but fails in a job. The notebook relied on
USE CATALOG. Use full three-part names in jobs.
Exercise
A user has READ VOLUME on main.default.landing but gets a permission error when listing /Volumes/main/default/landing/. Which privileges should you check, and why?
Show answer
Check USE CATALOG on main and USE SCHEMA on main.default. Access is checked at every level of the namespace, so READ VOLUME alone does not work without them.