The last time I worked on Databricks day to day, in 2020-21, tables lived in the workspace's Hive metastore, permissions were a patchwork of table ACLs and storage access, and every workspace had its own view of the world. Coming back to it now, the biggest change is Unity Catalog. It went GA last year, and it changes how you organise data, who can see what, and how you find things.
For anyone with a SQL Server background, Unity Catalog will feel more familiar than the old setup. This post maps the concepts across and shows a simple layout for insurance data: risk, premium and claim transactions as facts, with broker, coverholder and contract section dimensions.
The three-level namespace
In SQL Server you write database.schema.table. Unity Catalog adds one level above it:
1: catalog.schema.table 2: 3: SELECT * FROM prod.core.fct_premium;
| SQL Server | Unity Catalog |
|---|---|
| Instance | Metastore (one per region, shared by many workspaces) |
| Database | Catalog |
| Schema | Schema |
| Table / view | Table / view (plus volumes, functions and models) |
| Logins and database users | Account-level users, groups and service principals |
The metastore sits at the account level, so the same catalog is visible from every workspace attached to it. A table created in the engineering workspace can be queried from the analytics workspace without copying anything, as long as the permissions allow it.
A simple layout
I'd use one catalog per environment and schemas by purpose:
1: CREATE CATALOG IF NOT EXISTS dev; 2: CREATE CATALOG IF NOT EXISTS prod; 3: 4: USE CATALOG prod; 5: 6: CREATE SCHEMA IF NOT EXISTS raw COMMENT 'Feeds as received'; 7: CREATE SCHEMA IF NOT EXISTS core COMMENT 'Cleansed, conformed transactions and dimensions'; 8: CREATE SCHEMA IF NOT EXISTS reporting COMMENT 'Star schema and aggregates for Power BI';
A catalog per environment means the same code can run in dev and prod by changing one parameter, and a careless query in dev can't touch production tables. Schemas by purpose keep permissions simple: most people only ever need reporting.
Managed and external tables
A managed table stores its files in the storage location Unity Catalog controls. Drop the table and the data goes too, just like SQL Server. An external table points at files in your own storage path, and dropping it leaves the files in place.
1: CREATE TABLE prod.core.dim_coverholder ( 2: coverholder_key BIGINT GENERATED ALWAYS AS IDENTITY, 3: coverholder_id STRING NOT NULL, 4: coverholder_name STRING, 5: country STRING, 6: approval_status STRING 7: ); 8: 9: CREATE TABLE prod.raw.claims_raw 10: LOCATION 'abfss://feeds@mystorage.dfs.core.windows.net/claims/';
External paths go through two objects an admin sets up once: a storage credential (a managed identity or IAM role) and an external location that grants use of a path. Users never see keys, which is a big improvement on mounting storage with a service principal secret, as we used to.
Permissions feel like SQL Server again
Grants are standard SQL and are inherited downwards. To query a table you need USE CATALOG on the catalog, USE SCHEMA on the schema and SELECT on the table (or on the whole schema):
1: GRANT USE CATALOG ON CATALOG prod TO `analysts`; 2: GRANT USE SCHEMA ON SCHEMA prod.reporting TO `analysts`; 3: GRANT SELECT ON SCHEMA prod.reporting TO `analysts`; 4: 5: GRANT USE CATALOG ON CATALOG prod TO `engineers`; 6: GRANT ALL PRIVILEGES ON SCHEMA prod.core TO `engineers`; 7: GRANT ALL PRIVILEGES ON SCHEMA prod.reporting TO `engineers`; 8: 9: SHOW GRANTS ON SCHEMA prod.reporting;
Grant to groups, never to individuals. Groups come from your identity provider through account-level SCIM, so joiners and leavers are handled in one place.
Row-level security with dynamic views
In insurance, not everyone should see every coverholder's business. A class underwriter may only see their own class, and claims handlers may not need premium detail. A dynamic view filters rows based on who is asking:
1: CREATE OR REPLACE VIEW prod.reporting.v_premium_secure AS 2: SELECT p.* 3: FROM prod.reporting.fct_premium p 4: JOIN prod.reporting.dim_section cs 5: ON cs.contract_section_key = p.contract_section_key 6: WHERE is_account_group_member('all-classes') 7: OR (cs.class_of_business = 'Property' AND is_account_group_member('property-team')) 8: OR (cs.class_of_business = 'Marine' AND is_account_group_member('marine-team')); 9: 10: GRANT SELECT ON VIEW prod.reporting.v_premium_secure TO `analysts`;
Users get SELECT on the view but not on the underlying table. Hard-coding classes in the WHERE clause doesn't scale far, so for anything bigger, join to a mapping table of group to class or coverholder instead.
Lineage and discovery
Unity Catalog records lineage automatically for queries run on Databricks compute: which tables and columns fed a table, and which notebooks, jobs and dashboards read it. When someone asks where the GWP figure on a dashboard comes from, Catalog Explorer can show the path back to the raw feed. On SQL Server that question usually meant searching stored procedures for a column name.
Add comments and tags as you build, so search actually finds things:
1: COMMENT ON TABLE prod.reporting.fct_premium IS 2: 'One row per premium transaction from the bordereaux feed, in original and GBP amounts'; 3: 4: ALTER TABLE prod.reporting.fct_premium 5: ALTER COLUMN gross_premium_gbp COMMENT 'Gross written premium converted at month-end ROE';
Moving from the Hive metastore
Existing workspaces still have a hive_metastore catalog with the old tables. You can query it alongside Unity Catalog while you migrate. External tables can be upgraded in place with SYNC, and managed tables are usually copied with CREATE TABLE ... AS SELECT or DEEP CLONE. Plan it schema by schema, and update jobs to use three-part names as you go.
Quick recap
- Think of a catalog as a database, and use one per environment.
- Prefer managed tables. Use external locations instead of mounts and secrets.
- Grant to groups, at schema level where you can.
- Use dynamic views for row-level rules such as class of business or coverholder.
- Add comments as you build. Lineage does the rest.