Sub topic 14
Access Reviews and Ongoing Compliance Monitoring
This chapter assumes you can write SQL against Unity Catalog tables. It also assumes you know the catalog.schema.table namespace and the basic GRANT model. You should have read the earlier chapters on system.access.audit and on lineage permissions. Here you will turn those pieces into a repeatable review process.
What an access review is
An access review is a scheduled check that the people and groups who can reach sensitive data are the ones who should. Auditors usually ask for evidence of three things:
- Who has access to a sensitive object.
- Who actually used that access during a period.
- What was done about unusual or failed activity.
Unity Catalog gives you the raw material for the second and third points through system.access.audit. Lineage adds context. It shows which downstream tables inherit the sensitivity of a source table, so the review covers copies of the data as well as the original.
A review is only useful if it runs on a schedule and leaves a record. A one-off query answers a question once. A scheduled job that writes results to a table gives you a history you can show to someone else.
Prerequisites for the monitoring account
The audit and lineage system tables are not readable by ordinary users. A governance group needs explicit grants. Grant the minimum set, and grant it to a group instead of to individuals.
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 the audit table exposes user emails and request parameters across the whole account. Keep the group small. If reviewers only need part of the data, publish a filtered view or summary table in a governance schema and grant on that instead.
The review workflow
The workflow has four steps, and each step uses a query from earlier chapters.
- Scope. List the tables that hold regulated or sensitive data. Add the downstream tables found through lineage.
- Collect evidence. Query the audit table for access and failures, and the lineage tables for dependencies.
- Review. Show the results to the data owner, who confirms or rejects each access.
- Act. Revoke grants that are not needed, and store the decision.
Step 1: widen the scope with lineage
A table that is restricted at the source can be copied into a table that is not. Start from the source and find everything that reads from it.
SELECT DISTINCT
target_table_full_name,
entity_type
FROM system.access.table_lineage
WHERE source_table_full_name = 'main.sales.orders'
AND target_table_full_name IS NOT NULL;Each row is a candidate for the same review. If a downstream table copies a sensitive column, it needs the same controls. To check whether it does, use column lineage.
SELECT DISTINCT
source_table_full_name,
source_column_name,
target_column_name
FROM system.access.column_lineage
WHERE target_table_full_name = 'main.sales.daily_revenue'
AND target_column_name = 'revenue';Lineage only covers what Unity Catalog observed at runtime. It cannot see data copied outside Databricks or moved by tools that do not report lineage. A review that relies on lineage alone can miss those copies, so confirm the list with the data owner.
Step 2: collect access evidence
To see who looked at a table recently, filter the audit table to one object and a bounded date range.
SELECT
event_time,
user_identity.email AS user_email,
action_name,
request_params.full_name_arg AS table_name,
response.status_code
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND action_name = 'getTable'
AND request_params.full_name_arg = 'main.sales.daily_revenue'
AND event_date >= current_date() - INTERVAL 7 DAYS
ORDER BY event_time DESC;Always filter on event_date. The table is partitioned by date, so the filter keeps the scan small and the cost low.
A getTable event shows that someone requested the table's metadata. It does not prove that they read rows. Treat it as evidence of interest or access, and combine it with other signals before drawing conclusions.
Step 3: find failed requests
Repeated failures can mean a person who needs access and has not asked for it. They can also mean someone probing for data they should not see. This query counts failed Unity Catalog requests per user and action.
SELECT
user_identity.email AS user_email,
action_name,
count(*) AS event_count
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND event_date >= current_date() - INTERVAL 30 DAYS
AND response.status_code >= 400
GROUP BY user_identity.email, action_name
ORDER BY event_count DESC;Read the output with context. A service principal with thousands of failures on one action usually points to a misconfigured job. A person with failures across many different tables deserves a closer look.
Making the review repeatable
A query you run by hand is not a control. To turn it into one, schedule it and store the output.
A reasonable pattern:
- Create a schema such as
governance.reviewsthat only the governance group can write to. - Write each review run into a table with a run date column.
- Schedule the job weekly or monthly with a Databricks job.
- Add a SQL alert for conditions that need fast attention.
The following example stores a weekly summary of failed requests.
CREATE TABLE IF NOT EXISTS governance.reviews.failed_requests (
run_date DATE,
user_email STRING,
action_name STRING,
event_count BIGINT
);
INSERT INTO governance.reviews.failed_requests
SELECT
current_date() AS run_date,
user_identity.email AS user_email,
action_name,
count(*) AS event_count
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND event_date >= current_date() - INTERVAL 7 DAYS
AND response.status_code >= 400
GROUP BY user_identity.email, action_name;Each run appends a new batch. Because the rows carry run_date, you can compare weeks and see whether a pattern is growing.
Retention is why you copy the data
System tables keep data for a limited time. The retention period depends on the table and on your account, so check the current documentation for the tables you use. If an auditor asks about activity from two years ago, the source table may no longer hold it. Copying review results, and where required the underlying events, into your own tables gives you a record that outlasts the system table.
Common mistakes
| Mistake | Effect | Fix |
|---|---|---|
| No `event_date` filter | Slow, expensive scans | Always bound the date range |
| Treating `getTable` as proof of reading rows | Overstated findings | Use it as a signal and confirm with other evidence |
| Relying on lineage alone to find copies | Missed copies made outside Unity Catalog | Confirm with data owners |
| Granting audit access to many people | The audit data itself becomes a leak | Use a small group or a filtered view |
| Running reviews by hand | No history, inconsistent results | Schedule and store results |
| Ignoring service principals | Automated access goes unreviewed | Include them in the review scope |
Handling findings
Each finding needs a recorded outcome. Typical outcomes are:
- Confirmed: access is needed and stays.
- Revoked: access is removed with
REVOKE, and the date is noted. - Escalated: the activity looks suspicious and goes to the security team.
- Deferred: more information is needed, with an owner and a due date.
When you revoke access, use the same group-based model you used to grant it. For example, remove a user from the group instead of adding a user-specific deny. After a change, run the audit query again in the next cycle to confirm that the user's requests now fail, which is the expected result.
Exercise
A reviewer finds that main.sales.orders is restricted, but main.sales.daily_revenue is readable by many more users. Which two system tables help you decide whether the wider access is a problem, and what does each tell you?
Show answer
system.access.table_lineage shows whether daily_revenue is built from orders, and system.access.column_lineage shows whether sensitive columns flow into it. system.access.audit shows who has been requesting daily_revenue and whether those requests succeeded. Together they show whether sensitive data reached a less restricted table and who used it. Confirm with the data owner, because lineage does not cover copies made outside Unity Catalog.
Exercise
Why does the weekly review job write its results to a governance table instead of only showing the query output?
Show answer
System tables have limited retention, and a query output leaves no history. A governance table keeps each run with a run_date, so you can compare periods and show evidence to an auditor long after the source events have expired.