Sub topic 5
System tables: where governance data is exposed
This chapter assumes you know basic SQL, can run queries in a Databricks notebook or SQL warehouse, and understand the catalog.schema.table namespace and GRANT statements. It introduces system tables, the place where Unity Catalog publishes lineage and audit data. Later chapters query those tables in detail.
What system tables are
System tables are read-only tables, managed by Databricks, that hold operational data about your account. They live in a catalog named system. You query them with ordinary SQL, so you can filter, join, and aggregate them like any other table.
Governance data sits in the access schema:
| Table | What it holds |
|---|---|
| `system.access.table_lineage` | Which tables were read and written, and by which job, notebook, or query |
| `system.access.column_lineage` | The same relationships at column level |
| `system.access.audit` | Events such as table requests, grants, and logins |
Other schemas in the system catalog cover areas such as billing and compute. This tutorial uses only system.access.
Where the data comes from
Databricks writes to system tables for you. You do not create them or load data into them, and you cannot change their contents. Each table is available per metastore, so one query sees activity from the workspaces attached to that metastore.
Who can read them
Ordinary users cannot read these tables by default. An account admin must make the system schemas available, and then a metastore admin or another privileged user grants access. As with any securable, the reader needs three privileges: USE CATALOG on the catalog, USE SCHEMA on the schema, and SELECT on the table.
The following statements give a governance group read access to lineage and audit data and nothing else:
GRANT USE CATALOG ON CATALOG system TO `data-governance`;
GRANT USE SCHEMA ON SCHEMA system.access TO `data-governance`;
GRANT SELECT ON TABLE system.access.table_lineage TO `data-governance`;
GRANT SELECT ON TABLE system.access.column_lineage TO `data-governance`;
GRANT SELECT ON TABLE system.access.audit TO `data-governance`;Granting SELECT on individual tables, instead of the whole schema, limits what the group can see. This matters most for the audit table, because it records who did what and may contain user email addresses and object names.
Check that you can read them
Run a small query before building anything larger. Limit the rows, and filter on the date column so you scan less data:
SELECT event_time, action_name
FROM system.access.audit
WHERE event_date >= current_date() - INTERVAL 1 DAYS
LIMIT 10;If you get a permission error, one of the three privileges is missing. If the query runs but returns no rows, the schema may be enabled while no recent events match your filter. Widen the date range before assuming something is broken.
Common mistakes
- Granting
SELECTwithoutUSE CATALOGandUSE SCHEMA. The query still fails. - Scanning a whole table without a date filter. These tables grow continuously, so always filter on a date column such as
event_date. - Expecting events from other metastores. A query sees only the metastore it runs against.
- Treating system tables as permanent storage. Data is kept for a limited time, so copy what you need for long-term records. A later chapter covers retention.
Exercise
A data steward can run SELECT on other tables but gets a permission error on system.access.audit. Which three privileges must be in place, and why is granting only on the audit table preferable to granting on the whole access schema?
Show answer
The steward needs USE CATALOG on system, USE SCHEMA on system.access, and SELECT on system.access.audit. Granting SELECT only on the audit table exposes just that table. Granting on the whole schema would also expose the lineage tables and any other tables in the schema, which may be more than the steward needs.
Exercise
Why should a query against system.access.audit include a filter on event_date?
Show answer
The table grows continuously. A date filter limits how much data the query scans, which makes it faster and cheaper.