Unity Catalog row filters and column masks evaluate identity functions such as session_user() and is_account_group_member() for the principal running the query, so an application connected under its own machine identity gets that identity’s view of the data. To test this, run the same question as two differently entitled test users and read executed_by and executed_as in system.query.history. Expected rows and masks should differ between them, and the history should name each user. Repeat the test through every path that returns results, because dashboards, materialized view refreshes and caches can each use a different identity.
The filter is working, and you still have a problem
Row filters do not fail when an application uses one login for everyone. They evaluate correctly for whoever Databricks believes is asking, and that principal is the application. Suppose the filter below is on your sales table and the application’s machine identity has been placed in the admin group so the connection test would pass. Every user of that application now gets all regions, with no error anywhere and a governance review that shows the filter in place.
Databricks spells out the mechanism. Filters run with definer’s rights, except for functions that check user context, and session_user and is_account_group_member run as the invoker. The policy is only as personal as the invoker. A sign-in screen in front of the application changes nothing about this, since the warehouse session may belong to someone else entirely.
CREATE FUNCTION gov.policies.sales_region_filter(row_region STRING)
RETURN IF(is_account_group_member('sales_admins'), true,
EXISTS (SELECT 1 FROM gov.policies.region_access a
WHERE a.username = session_user()
AND a.region = row_region));
ALTER TABLE main.sales.orders
SET ROW FILTER gov.policies.sales_region_filter ON (region);
CREATE FUNCTION gov.policies.email_mask(email STRING)
RETURN CASE WHEN is_account_group_member('sales_admins')
THEN email ELSE '***' END;
ALTER TABLE main.sales.orders
ALTER COLUMN customer_email SET MASK gov.policies.email_mask;Map every path before you test one
One Databricks deployment can answer the same question through paths that use different identities. The identity on each path follows from how it was set up, so write down the setup first. A Databricks App, for example, has two authorization models. With app authorization it uses its own dedicated machine identity, and all users share that access. With user authorization it forwards the signed-in user’s token, and their Unity Catalog policies apply. Two different security postures, and they look the same on the screen. OAuth machine-to-machine sign-in authenticates a machine identity, while user-to-machine sign-in produces a token that acts for the user who signed in through a browser.
Dashboards deserve special attention. A dashboard published with shared data permissions runs viewers’ queries under the publisher’s credentials, and Databricks says plainly that this might expose data to users without direct access. Individual data permissions run under the viewer’s credentials. Materialized views have a split of their own: during a pipeline refresh the filter and mask functions see the pipeline owner, and when somebody queries the view they see that person.
Read the identity from the source
Screens can claim anything, so take the evidence from Databricks. In system.query.history, executed_by is the user who ran the statement and executed_as is the user or machine identity whose privilege was used. Run a question as your test user, then find that statement. If both columns name the application’s machine identity, policies were evaluated against that identity.
A few practical details will save you time. Only admins can read this table by default, and Databricks recommends a dynamic view when you share it. Records typically appear within an hour, so do not panic if your test run is missing at first. statement_text returns REDACTED unless you are an account admin or in the databricks_pii_access group, so your test may need to match on time, warehouse and user instead of text. client_application comes from what the client reports, so treat it as a hint. For a wider audit, system.access.audit records run_by and run_as in identity_metadata, and acting_resource identifies an OAuth app acting for a user.
SELECT start_time,
executed_by,
executed_as,
client_application,
execution_status,
statement_id
FROM system.query.history
WHERE compute.warehouse_id = 'abc123'
AND start_time >= current_timestamp() - INTERVAL 2 HOURS
ORDER BY start_time DESC;A two-persona test with expected results
Write down the expected answers before you run anything. A persuasive explanation from an AI system is very good at making a wrong number feel fine afterwards. The synthetic table below uses invented totals: East holds 400 and West holds 600. Use artificial values in the email column as well, so a failure discloses nothing. Persona A sees East only. Persona B sees both regions and the raw email. Persona C has no entry in the mapping table.
| Check | Persona A (East) | Persona B (both) | Persona C (none) |
|---|---|---|---|
| Total sales | 400 | 1,000 | No rows; must not read as 0 sales |
| Breakdown by region | East only | East and West | No rows |
| Show a customer email | *** | Raw test value | No rows |
| Group by customer email | One masked bucket, or a refusal | Per value | No rows |
| executed_by in history | Persona A | Persona B | Persona C |
Then attack the result
- Order of runsRun persona B first, then A. A cache that omits identity shows up here. Dashboard caches differ by mode: shared data permissions use a shared cache, and individual data permissions a per-user one.
- Other outputsCheck downloads, saved results, scheduled deliveries and the evidence panel. Generated explanations can restate values the table masked.
- Empty versus zeroPersona C should see an empty result, and the application should describe it that way. Runtimes older than 12.2 LTS also fail securely and return no data, so an unexpected empty result can be a compute problem.
- RevocationRemove persona A from East in the mapping table, then ask again, and time how long any cached copy lasts.
- Bypass routesTime travel, clones, path-based access and Delta APIs are not supported on tables with these controls. Find out what your application does when a generated query or export attempts one.
Policy design that keeps the test passing
Avoid broad admin branches in the function, or keep the group they check very small, and never add an application principal to it as a shortcut. Prefer deterministic SQL functions over Python, as Databricks advises for performance, and match parameter types to column types. With ANSI mode off, uncastable values become NULL, and a filter that looks fine in review can then return wrong results with no error. Filters cannot go on views, and the tables a policy references may not have active filters or masks of their own, so keep your mapping table in a separately governed schema.
Databricks now recommends attribute-based access control with governed tags for policies that span many tables, keeping table-level functions for per-table logic. The same test applies either way. ABAC also offers a Beta context attribute, request.is_on_behalf_of, which is true for any request from an OAuth app. It lets you restrict agents acting for a user while the data stays reachable when that user queries directly. Treat it as a further control you might add once the identity is correct, and retest after any compute or policy change.
Run the persona table with the vendor
A successful administrator query proves connectivity and nothing more, from us or anyone else on Databricks. Ask the vendor to run the persona table with you against test data, and read executed_by and executed_as yourself and don’t settle for a statement about identity. Include one question the persona should not be able to answer, and check what they are told. Our connector catalog is at https://nexatron.io/connectors.
Bring three business questions
Explore your sources, definitions, and review criteria with our team. Please keep credentials and sensitive records out of the inquiry.