DataEng Hub
DatabricksbeginnerArticle · 7 min read

Unity Catalog Explained: Metastore, Catalogs, Schemas and Volumes

How Unity Catalog organizes data on Databricks: metastore, catalogs, schemas, tables and volumes, with the SQL to set each one up.

Balaji S.
Lead Data Engineer

Unity Catalog looks like a lot of new vocabulary. It is really four boxes inside each other, and once you see them, every permission error starts to make sense.

TL;DR

  • Unity Catalog is one governance layer for the whole Databricks account, not one per workspace.
  • The hierarchy is metastore, catalog, schema, then objects: tables, views, volumes, functions and models.
  • Every object has a three-part name: catalog.schema.object. Get used to typing all three.
  • Volumes are for files what tables are for rows. They replace mount points and loose storage paths.
  • To read a table you need three grants, not one: USE CATALOG, USE SCHEMA and SELECT.

The problem

NorthBridge Retail, a fictional chain, runs three Databricks workspaces: dev, test and prod. Each has its own Hive metastore, so every table is registered three times and every permission is granted three times.

Files are worse. Raw data sits behind mount points that share one storage key, so anyone who can open a notebook can read every file. When the auditor asks who can see customer data, the honest answer is "we would have to check each workspace".

Unity Catalog exists to remove that answer. It moves tables, files and permissions out of the workspace and into one place that all workspaces share.

Key concepts

Everything in Unity Catalog lives in one tree, and the catalog is the level where you separate data. The metastore is the root — you rarely touch it after setup; most accounts have one per cloud region. The catalog is where the real decisions happen: which environment, which business domain, which storage account.

Concept What it means Why it matters here
Three-level name catalog.schema.object The same name works in every workspace on the metastore
Managed storage location Where Unity Catalog puts managed data, set per catalog or schema Prod and dev data can sit in different storage accounts
Managed vs external Managed: Unity Catalog owns the files. External: you do Decides what happens to the files on DROP
Volume A governed folder for non-tabular files Raw CSVs get grants, the same way tables do
Privilege inheritance A grant on a catalog or schema flows down to what is inside One grant can cover today's tables and tomorrow's

Step-by-step implementation

Environment for all code: a Unity Catalog enabled workspace on Azure, a SQL warehouse or Databricks Runtime 16.4 LTS. You need the CREATE CATALOG privilege on the metastore, and an external location that covers the storage path in step 1. The groups analysts and data-engineers already exist at account level.

Step 1 — Create the catalog

A catalog is your isolation boundary, so give it its own storage. Everything managed inside it will land under this path.

CREATE CATALOG IF NOT EXISTS northbridge_prod
MANAGED LOCATION 'abfss://uc-prod@nbretaildata.dfs.core.windows.net/managed'
COMMENT 'Production data for NorthBridge Retail';

The usual pattern is one catalog per environment: northbridge_dev, northbridge_test, northbridge_prod. Larger companies add the domain too, such as sales_prod.

Step 2 — Create schemas

Schemas group objects inside a catalog. Use them for business domains or for medallion layers, whichever your readers think in.

CREATE SCHEMA IF NOT EXISTS northbridge_prod.landing
COMMENT 'Raw files as received from stores';
 
CREATE SCHEMA IF NOT EXISTS northbridge_prod.sales
COMMENT 'Cleaned sales tables';

Step 3 — Create a table and a volume

A table with no LOCATION clause is a managed table. Unity Catalog decides where the files go and cleans them up when the table is dropped.

CREATE TABLE IF NOT EXISTS northbridge_prod.sales.orders (
  order_id   BIGINT,
  store_id   STRING,
  amount     DECIMAL(12,2),
  order_date DATE
);
 
CREATE VOLUME IF NOT EXISTS northbridge_prod.landing.raw
COMMENT 'Nightly order files';

The volume gets a path that mirrors its name. Any tool that reads files can use it.

# List files and read one folder of CSVs from the volume
display(dbutils.fs.ls("/Volumes/northbridge_prod/landing/raw"))
 
df = (spark.read
    .option("header", "true")
    .csv("/Volumes/northbridge_prod/landing/raw/orders/"))

No storage keys, no mount points. Access to those files is now a grant, like any table.

Step 4 — Grant access

Analysts read the sales schema. Engineers load files into the volume.

GRANT USE CATALOG ON CATALOG northbridge_prod TO `analysts`;
GRANT USE SCHEMA, SELECT ON SCHEMA northbridge_prod.sales TO `analysts`;
 
GRANT USE CATALOG ON CATALOG northbridge_prod TO `data-engineers`;
GRANT USE SCHEMA ON SCHEMA northbridge_prod.landing TO `data-engineers`;
GRANT READ VOLUME, WRITE VOLUME
  ON VOLUME northbridge_prod.landing.raw TO `data-engineers`;
 
SHOW GRANTS ON SCHEMA northbridge_prod.sales;

SELECT on the schema covers every table in it, including tables created next month. That one line replaces a grant per table.

Notice that analysts got nothing on landing. They cannot see the raw files, and you did not have to deny anything.

From production: gotchas and lessons

The model is clean. The surprises come from old habits carried over from Hive.

  1. Symptom: A user has SELECT on a table and still gets a permission error. Cause: They are missing USE CATALOG or USE SCHEMA on the parents. A table grant alone does not open the path to it. Fix: Grant usage at catalog and schema level to the group first, then the data privilege.
  2. Symptom: A notebook in the dev workspace can query production tables. Cause: A catalog is visible from every workspace attached to the metastore unless you say otherwise. Workspaces are not a data boundary any more. Fix: Bind the prod catalog to the prod workspace, and keep grants tight as the second lock.
  3. Symptom: A table is dropped and the data goes with it, or an external table is dropped and the storage bill does not move. Cause: Managed and external objects have opposite lifecycles. Unity Catalog deletes managed files; it never touches external ones. Fix: Default to managed. Use external only when another system must read the files directly, and write that reason down.
  4. Symptom: Nobody can change grants on a table because its owner left the company. Cause: The person who creates an object owns it. Fix: Create production objects with a service principal, or run ALTER TABLE ... OWNER TO a group straight after creation.

Performance and cost notes

Unity Catalog is a governance layer, so its effect on cost is indirect.

  • Storage per catalog: Databricks recommends catalog-level managed storage over one metastore-wide location. A side benefit is that each environment's storage bill is easy to read.
  • Managed tables: Only Unity Catalog managed tables qualify for predictive optimization, which runs compaction and vacuum for you.
  • Fewer grants: Grant to groups at schema level. Thousands of table-level grants to individuals are slow to audit and easy to get wrong.
  • System tables: Audit logs, billing usage and lineage are queryable as tables. Use them before building your own tracking.

When not to use this

On Databricks today there is little reason to avoid Unity Catalog. The legacy Hive metastore is deprecated. The honest limits are about how you use it.

  • Tools that read storage directly: Anything that bypasses Databricks also bypasses Unity Catalog. Keep such tools out of managed storage and give them external tables or Delta Sharing.
  • Cross-region data: A metastore covers one region. Sharing across regions is a design decision, not a default.
  • Catalog sprawl: A catalog per team per project per environment turns governance into bookkeeping. Start with environments and add catalogs only for a real isolation need.

Checklist

  • One catalog per environment, each with its own managed storage location
  • Prod catalog bound to the prod workspace only
  • Schemas named for domains or layers, with a comment on each
  • Raw files in volumes, no mount points or storage keys in notebooks
  • Grants go to groups, at schema level where possible
  • Production objects owned by a group or service principal, never a person

Practice

  • Create a catalog, a schema and a table, then query the table by its full three-part name from a second workspace.
  • Grant a test user SELECT on one table only. Note the error they get, then add USE CATALOG and USE SCHEMA and try again.
  • Upload a CSV to a managed volume and read it with spark.read using the /Volumes/... path.

Watch

Further reading

#unity-catalog#governance#volumes#metastore

Keep going

One practical note a week

Get new articles, problems and guides in your inbox.