Why governance matters
ShopKart now has orders, customer emails and revenue. Analysts should see gold revenue, but not customer emails. Support may see emails. Interns should see nothing in prod. And when a number is wrong, everyone asks: βWhere did this come from?β Unity Catalog answers all of that in one place.
The object hierarchy
ποΈMetastore
Top level: one per region, attached to your workspaces
πCatalog
e.g. shopkart (or dev / prod)
πSchema (database)
e.g. bronze, silver, gold, raw
π§©Objects inside a schema
Tables
Managed or external
Views
Saved queries
Volumes
Files: CSV, JSON, images
Functions
SQL/Python UDFs
Models
ML models
So shopkart.silver.orders means catalog shopkart, schema silver, table orders. The same table is visible from every workspace attached to the metastore.
Creating ShopKart's structure
CREATE CATALOG IF NOT EXISTS shopkart;
CREATE SCHEMA IF NOT EXISTS shopkart.raw;
CREATE SCHEMA IF NOT EXISTS shopkart.bronze;
CREATE SCHEMA IF NOT EXISTS shopkart.silver;
CREATE SCHEMA IF NOT EXISTS shopkart.gold;
-- A volume for the landing files (this is /Volumes/shopkart/raw/landing/)
CREATE VOLUME IF NOT EXISTS shopkart.raw.landing;
-- Make shopkart the default, so plain "silver.orders" works in this session
USE CATALOG shopkart;Managed vs external tables
| Managed table | External table | |
|---|---|---|
| Who picks the location | Unity Catalog | You (LOCATION 's3://...') |
| DROP TABLE | Deletes data too (UNDROP possible for 7 days) | Removes only the definition; files stay |
| Maintenance | Can use predictive optimization (automatic OPTIMIZE/VACUUM) | You manage it |
| Use when | Default for almost everything | Data shared with other tools or must sit at a fixed path |
-- External locations connect Unity Catalog to a cloud path, using a storage credential (set up by an admin)
CREATE EXTERNAL LOCATION IF NOT EXISTS partner_drop
URL 's3://shopkart-partner-drop/'
WITH (STORAGE CREDENTIAL shopkart_s3_cred);
-- An external table at that location
CREATE TABLE shopkart.bronze.partner_orders
LOCATION 's3://shopkart-partner-drop/orders/';Permissions with GRANT
Permissions are inherited downwards: a grant on a schema covers its current and future tables. To read a table you need USE CATALOG on its catalog, USE SCHEMA on its schema, and SELECT on the table or schema. Grant to groups, not individual people.
-- Analysts can read every gold table, nothing else
GRANT USE CATALOG ON CATALOG shopkart TO `analysts`;
GRANT USE SCHEMA ON SCHEMA shopkart.gold TO `analysts`;
GRANT SELECT ON SCHEMA shopkart.gold TO `analysts`;
-- Data engineers can create and change tables in silver
GRANT USE SCHEMA, CREATE TABLE, MODIFY, SELECT ON SCHEMA shopkart.silver TO `data_engineers`;
-- Check and undo
SHOW GRANTS ON SCHEMA shopkart.gold;
REVOKE SELECT ON SCHEMA shopkart.gold FROM `analysts`;| Privilege | Allows |
|---|---|
| USE CATALOG / USE SCHEMA | Open the container (needed for anything inside) |
| SELECT | Read a table or view |
| MODIFY | Insert, update, delete, merge |
| CREATE TABLE / CREATE SCHEMA | Create objects inside |
| READ VOLUME / WRITE VOLUME | Read or write files in a volume |
| ALL PRIVILEGES | Everything (use sparingly) |
| Ownership | The owner can grant others and drop the object |
Row filters and column masks
Sometimes people may see a table but not every row or column. Unity Catalog applies SQL functions automatically on every query:
-- Column mask: only the support group sees real emails
CREATE OR REPLACE FUNCTION shopkart.silver.mask_email(email STRING)
RETURN CASE WHEN is_account_group_member('support') THEN email ELSE '*****' END;
ALTER TABLE shopkart.silver.customers
ALTER COLUMN email SET MASK shopkart.silver.mask_email;
-- Row filter: the Kolkata team sees only Kolkata rows; admins see all
CREATE OR REPLACE FUNCTION shopkart.gold.city_filter(city STRING)
RETURN is_account_group_member('admins') OR city = 'Kolkata';
ALTER TABLE shopkart.gold.daily_city_revenue
SET ROW FILTER shopkart.gold.city_filter ON (city);Before row filters existed, teams used dynamic views with the same functions in a WHERE clause. You'll still see them.
Lineage and auditing
- Lineage: Unity Catalog records which tables and columns each table was built from, automatically, for SQL and Python. Open
gold.daily_city_revenuein Catalog Explorer and you'll see it came fromsilver.ordersandsilver.customers, and those from bronze. Great for impact analysis (βwhat breaks if I change this column?β). - Audit logs: who read or changed what, and when (via system tables like
system.access.audit). - System tables: billing usage, job runs, lineage, queryable with SQL in the
systemcatalog.
Sharing outside your company: Delta Sharing
Delta Sharing is an open protocol to share live tables with other organisations (even if they don't use Databricks) without copying data. You create a share, add tables, and give a recipient access.
A common environment setup
| Catalog | Who writes | Who reads |
|---|---|---|
| dev | Every engineer (their own schemas) | Engineers |
| staging | CI/CD deployments only | Testers |
| prod | Production jobs' service principal only | Analysts (gold), engineers (read) |
A service principal is a non-human identity that production jobs run as, so pipelines don't break when an employee leaves.
π― Interview questions on this topic
Try to answer out loud first, then tap to check.
Q1What is Unity Catalog?Fresher+
Q2Managed vs external tables?Fresher+
Q3What is the difference between Unity Catalog and the Hive metastore?1β3 yrs+
Q4How would you give analysts access to only the gold layer?1β3 yrs+
Q5How do you protect PII like emails?3+ yrs+
Q6What are storage credentials and external locations?3+ yrs+
Key takeaways
- βUnity Catalog gives every data asset one name, one permission model and automatic lineage.
- βUse managed tables by default and volumes for raw files.
- βGrant to groups at the schema level; protect PII with masks and filters.
- βSeparate dev/staging/prod catalogs and run prod as a service principal.
Frequently asked questions
What is Unity Catalog in simple words?
Unity Catalog is Databricks' single place to manage data: it knows every table, view, volume, model and function, who may use them, where they came from (lineage) and who accessed them (audit logs), across all workspaces.
What is the three-level namespace?
Every table is named catalog.schema.table, for example shopkart.silver.orders. Catalogs often separate environments or business units, schemas group related tables, and tables hold the data.
Managed or external table: which should I use?
Managed by default: Unity Catalog chooses the storage location and manages the files, and dropping the table deletes the data (recoverable for a short time). Use external tables when data must live at a specific path or is shared with other tools.
What is the old Hive metastore?
Before Unity Catalog, each workspace had its own Hive metastore with only workspace-level permissions. It still appears as the hive_metastore catalog. New work should use Unity Catalog; migrating from Hive metastore is a common project.
What is a volume?
A volume is a Unity Catalog object for files that aren't tables: CSVs, JSON, images, PDFs. It has a path like /Volumes/catalog/schema/volume/ and the same permission model as tables.
π§ Quick check: Unity Catalog
1. What is the full name of a table in Unity Catalog?
2. To SELECT from shopkart.gold.revenue, a user needs...
3. You DROP a managed table. What happens to its files?
4. Where do raw CSV files go in Unity Catalog?
Checking your accessβ¦