DatabricksZero to Advanced

Unity Catalog (UC) governs data and AI assets across workspaces: access control, lineage, auditing, discovery.

  • Everything you built so far already lives in UC: catalog.dbx_course.orders
  • Hands-on where Free Edition allows it. Account-level topics are explanation only (no account console, one workspace, one metastore)
  • Setup cell for the examples:
Python
catalog = spark.sql("SELECT current_catalog()").first()[0]
spark.sql(f"USE SCHEMA {catalog}.dbx_course")
print(catalog)

On Free Edition

You are the only user. Granting and masking still work on your own objects, so you can practise the syntax. You can't invite users or create account-level groups.

6.01Concept

Unity Catalog Architecture

By the end: draw the Unity Catalog object model and say which objects sit above and below the catalog.

Metastoretop-level containerholdsCataloga data domain or environmentholdsSchemaa group of objectsholdsTable, view, volume, function, model
Every asset is addressed as catalog.schema.object.
  • Securable object: anything you can grant privileges on
  • Metastore-level objects: storage credentials, external locations, connections, shares
  • UC works across workspaces: one place for permissions, lineage and audit
  • Enabled automatically for workspaces created after November 8, 2023
SQL
%sql
SHOW CATALOGS
Python
display(spark.sql("SELECT current_metastore() AS metastore"))

Remember

Govern once in UC. Every workspace, notebook, job and SQL warehouse then follows the same rules.

6.02Hands-on on Free Edition

Metastore, Catalog, Schema, and Table

By the end: create catalogs, schemas and tables and find them with SHOW commands and the information schema.

SQL
%sql
SHOW SCHEMAS
SQL
%sql
SHOW TABLES IN dbx_course
Python
display(spark.sql(f"""
    SELECT table_name, table_type, data_source_format
    FROM {catalog}.information_schema.tables
    WHERE table_schema = 'dbx_course'
"""))
  • information_schema exists in every catalog: tables, columns, schemata, volumes, privileges
  • Create a schema for experiments:
SQL
%sql
CREATE SCHEMA IF NOT EXISTS sandbox COMMENT 'Throwaway experiments'
Level Create with Note
Catalog CREATE CATALOG May need privileges Free Edition doesn't give you
Schema CREATE SCHEMA Needs CREATE SCHEMA on the catalog
Table CREATE TABLE Needs USE SCHEMA + CREATE TABLE

Naming

Catalog per environment or domain (dev, prod), schema per layer or subject (bronze, silver, sales). Always use full three-level names in jobs.

6.03Concept

Managed vs External Storage

By the end: explain who owns the files of a managed object and what changes for an external one.

ManagedUC owns the fileslives in managed storagedrop = data deletedmaintained for youExternalyou own the filesstays in your storagedrop = metadata onlyyou maintain
  • Managed storage can be set per metastore, catalog or schema. Objects use the closest one
  • Managed tables are the default and recommended type
  • External tables and volumes: UC governs access, you manage the files and their lifecycle
  • Pick external only when other tools must write the same files, or the data must stay where it is
6.04Concept

Storage Credentials and External Locations

By the end: explain how storage credentials and external locations let UC reach cloud storage.

Storage credentialaccess to a cloud identityExternal locationcredential + pathTables or volumesexternal data
Users never get the cloud keys. They get privileges on the external location.
  • Storage credential: the cloud identity (IAM role, managed identity, service account) UC uses
  • External location: a path plus the credential that opens it
  • Privileges: CREATE EXTERNAL TABLE, READ FILES, WRITE FILES on the location
  • Paths of external locations can't overlap in confusing ways: plan the layout up front

On Free Edition

Custom storage locations aren't supported, so this is explanation only. Use managed tables and volumes.

6.05Hands-on on Free Edition

Volumes

By the end: create managed volumes, set volume privileges and use them from Spark and Python.

SQL
%sql
CREATE VOLUME IF NOT EXISTS sandbox.files
Python
path = f"/Volumes/{catalog}/sandbox/files"
with open(f"{path}/note.txt", "w") as f:
    f.write("hello volume\n")

print(open(f"{path}/note.txt").read())
display(dbutils.fs.ls(path))
  • Path: /Volumes/<catalog>/<schema>/<volume>/.... Works with Spark, dbutils.fs, os and open
  • Privileges: READ VOLUME, WRITE VOLUME
  • Managed volume: UC owns the storage. External volume: points at a location you registered
  • Use volumes for files (CSV, JSON, images, wheels, checkpoints). Use tables for tabular data
SQL
%sql
DESCRIBE VOLUME sandbox.files

Don't use the DBFS root

It's legacy and may be disabled. Volumes are governed, permissioned and the supported place for files.

6.06Concept

Users, Groups, and Service Principals

By the end: tell users, groups and service principals apart and say who should own what.

Usera personemail logininteractive workGroupa set of usersgrant to groupseasy to auditService principalan identity for automationruns jobs and CIno person's token
  • Grant to groups, not individuals. People join and leave groups
  • Run production as a service principal, so jobs don't depend on one person's account
  • Identities are managed at the account level and assigned to workspaces
  • Built-in groups: account users (everyone), admins (workspace admins)

On Free Edition

One workspace, one user, no account console, no SSO or SCIM. Explanation only.

6.07Hands-on with caveats

Privileges and Access Control

By the end: grant, check and revoke privileges and explain how inheritance works.

CatalogUSE CATALOGinherited bySchemaUSE SCHEMAinherited byTableSELECT, MODIFY
A privilege on a parent applies to objects below it. Reading a table needs all three levels.
SQL
%sql
SHOW GRANTS ON SCHEMA dbx_course
SQL
%sql
GRANT USE SCHEMA, SELECT ON SCHEMA dbx_course TO `account users`
SQL
%sql
REVOKE SELECT ON SCHEMA dbx_course FROM `account users`
Privilege Allows
USE CATALOG, USE SCHEMA See and reach the container
SELECT Read a table or view
MODIFY Insert, update, delete, merge
CREATE TABLE Create tables in a schema
EXECUTE Run a function or use a model
READ VOLUME, WRITE VOLUME Read or write files in a volume
MANAGE Manage grants on the object
  • Every object has an owner with all privileges. Transfer: ALTER TABLE t OWNER TO ...
  • REVOKE succeeds even if the privilege wasn't granted

On Free Edition

You are the only user, so these changes have no visible effect. The point is the syntax. Revoke what you grant.

Least privilege

Grant USE CATALOG + USE SCHEMA + SELECT to a group for read access. Give MODIFY and CREATE TABLE only to pipelines.

6.08Hands-on on Free Edition

Row Filters and Column Masks

By the end: hide rows and mask columns with row filters and column masks.

Row filtera function returns true or falsehides whole rowsColumn maska function returns the value or a masked onehides cell content

Column mask (hide customer names from everyone except a group):

SQL
%sql
CREATE OR REPLACE TABLE customers_masked AS SELECT * FROM customers
SQL
%sql
CREATE OR REPLACE FUNCTION mask_name(name STRING)
RETURNS STRING
RETURN CASE WHEN is_account_group_member('pii_readers') THEN name ELSE '***' END
SQL
%sql
ALTER TABLE customers_masked ALTER COLUMN name SET MASK mask_name
SQL
%sql
SELECT customer_id, name, country FROM customers_masked LIMIT 3
  • You're not in pii_readers, so name shows ***

Row filter (only show Dutch customers to everyone not in a group):

SQL
%sql
CREATE OR REPLACE FUNCTION nl_only(country STRING)
RETURNS BOOLEAN
RETURN country = 'NL' OR is_account_group_member('all_countries')
SQL
%sql
ALTER TABLE customers_masked SET ROW FILTER nl_only ON (country)

Remove both:

SQL
%sql
ALTER TABLE customers_masked DROP ROW FILTER
SQL
%sql
ALTER TABLE customers_masked ALTER COLUMN name DROP MASK

Limits

Not on views. No time travel, deep or shallow clones, or Delta Lake APIs on a table with a filter or mask. Keep ANSI mode on so bad casts raise errors instead of becoming NULL. For many tables use ABAC policies.

6.09Hands-on with caveats

Data Lineage

By the end: find where a table's data comes from and goes to using lineage.

ordersorder_linesjoined and enrichedrevenue_by_category
Lineage shows tables and columns upstream and downstream, captured automatically.
  • UC records lineage from queries run on UC-enabled compute: tables, views, columns, notebooks, jobs, pipelines
  • See it in Catalog Explorer: open a table, then the Lineage tab
  • Try: create a derived table and look at its lineage
Python
spark.sql("""
  CREATE OR REPLACE TABLE revenue_by_category AS
  SELECT p.category, SUM(o.quantity * p.unit_price) AS revenue
  FROM orders o JOIN products p USING (product_id)
  GROUP BY p.category
""")
  • Lineage can take a few minutes to appear
  • Uses: impact analysis before a change, debugging a bad number, compliance questions
  • Queryable through system tables and the lineage API where enabled

On Free Edition

I couldn't confirm which lineage and system-table features your workspace exposes. Check the Lineage tab. Skip what's missing.

6.10Hands-on on Free Edition

Data Discovery and Classification

By the end: document and tag data so people can find it, and know what automatic classification does.

SQL
%sql
COMMENT ON TABLE orders IS 'One row per order. Orders can include duplicates in the raw layer.'
SQL
%sql
ALTER TABLE customers SET TAGS ('domain' = 'sales', 'contains_pii' = 'true')
SQL
%sql
ALTER TABLE customers ALTER COLUMN name SET TAGS ('pii' = 'name')
Python
display(spark.sql(f"""
    SELECT * FROM {catalog}.information_schema.table_tags
    WHERE schema_name = 'dbx_course'
"""))
  • Find assets with the search bar and Catalog Explorer filters (owner, tag, type)
  • Comments (table and column) feed search and AI-generated descriptions
  • Tags drive policies: classify once, apply masks and access rules by tag
  • Automatic data classification can detect sensitive data types and tag them. Availability depends on your workspace

Habit

Every table gets a comment, an owner and a domain tag. Every PII column gets a tag.

6.11Concept

Auditing and Monitoring

By the end: explain how auditing and system tables show who accessed what.

ActionsAudit logwho, what, whenSystem tablesQueries and alerts
Access and activity are recorded and queryable with SQL.
  • System tables live in the system catalog: system.access.audit, lineage tables, billing usage, query history
  • A metastore admin enables each schema of system tables
  • Typical questions: who read the customer table, who changed a grant, which jobs touch this data
  • Retention and availability vary by system table: check the docs
SQL
SELECT event_time, user_identity.email, action_name
FROM system.access.audit
WHERE event_date >= current_date() - 7
ORDER BY event_time DESC
LIMIT 20

On Free Edition

I couldn't confirm system tables are available. The query above is for a full workspace.

6.12Concept

Delta Sharing

By the end: explain how Delta Sharing shares data with other organisations or platforms without copying it.

Providercreates a shareSharetables, volumes, viewsRecipientreads live data
Sharing is read access to the data in place. No copies, no extra pipelines.
  • Open protocol: recipients may be on Databricks (Databricks-to-Databricks) or not (pandas, Spark, Power BI, ...)
  • Provider side: CREATE SHARE, ALTER SHARE ... ADD TABLE, CREATE RECIPIENT, GRANT SELECT ON SHARE
  • Recipient side: mount the share as a catalog
  • Control access like any UC object. Audit who reads what

On Free Edition

Explanation only: I couldn't confirm sharing is available.

6.13Concept

Lakehouse Federation

By the end: explain how Lakehouse Federation queries external databases through UC.

Connectionhost + credentialsForeign catalogmirrors the databaseQuerypushed down to the source
You query the external system with the same three-level names and the same governance.
  • Sources include PostgreSQL, MySQL, SQL Server, Snowflake, BigQuery and others
  • Queries run in place: no ingestion, no copy
  • Fine for exploration and small lookups. For heavy or repeated use, ingest into Delta (Module 7)
  • Governance (grants, lineage, audit) applies to foreign catalogs too

On Free Edition

Outbound internet is limited to trusted domains, so reaching your own database isn't possible. Explanation only.

6.14Concept

Governance Across Workspaces

By the end: explain how one metastore governs many workspaces and how to separate environments.

Metastoreone per regionattached toWorkspacesdev, test, prodbound toCatalogsdev, test, prod
Workspace-catalog binding limits which workspace can see which catalog.
  • One metastore per cloud region is the usual design. All workspaces in the region attach to it
  • Same users, groups and grants everywhere. Bind a catalog to the workspaces that may use it
  • Common layouts: catalog per environment (dev, prod), or per domain
  • Share across regions or clouds with Delta Sharing

Environments

Separate dev and prod by catalog (and bind prod to the prod workspace). Code stays identical: only the catalog name changes (Module 26).

Recap

What you can do now

  • UC object model, three-level names, managed vs external
  • Volumes for files, information_schema to explore
  • Grant to groups, run automation as service principals
  • Row filters, column masks, comments and tags
  • Lineage, audit, sharing, federation and multi-workspace design