What you will be able to do
- Attach a row filter or column mask to one table with ALTER TABLE, and put the identity check inside the UDF
- Explain how governed tags, their inheritance and their assignment permissions make them safe to use as policy attributes
- Write a CREATE POLICY statement whose WHEN, MATCH COLUMNS, ON COLUMN and USING COLUMNS clauses match the UDF signature
- Choose between an ABAC policy and a table-level filter or mask, and say what happens when both apply
- Predict how ABAC fails closed when the runtime is too old, when an operation is unsupported, or when a tag or UDF is deleted
Key concept
Tag-matched policy — An ABAC policy is attached once to a catalog, schema or table. It applies its row filter or column mask to every table and column below that point whose governed tags match its conditions, including objects created and tagged later, so nobody has to edit each table's DDL.
1.Row filters and column masks on a single table
With row filters and column masks, one table returns different results to different people. A row filter is a boolean function: rows where it returns FALSE are left out of the result. A column mask takes the column value and returns either that value or a redacted version. Both are Unity Catalog functions (SQL and Python UDFs registered in UC). The engine calls them on every query, so the people who query the table never have to call them.
The UDF itself decides who the caller is. Unity Catalog doesn't pass in a role. The function checks membership with a call such as is_account_group_member() and branches on the result. The mask below shows the real SSN to HR and a placeholder to everyone else:
CREATE FUNCTION ssn_mask(ssn STRING)
RETURN CASE WHEN is_account_group_member('HumanResourceDept') THEN ssn ELSE '***-**-****' END;To attach these functions to one table at a time, use DDL. ALTER TABLE <table_name> SET ROW FILTER <function_name> ON (<column_name>, ...) binds a filter to columns, and ALTER TABLE <table_name> ALTER COLUMN <col_name> SET MASK <mask_func_name> binds a mask to one column. You can also declare a filter when the table is created. The columns you pass have to fit the function's parameters. If the types differ, the value is implicitly cast, and with ANSI mode disabled a value that can't be cast silently becomes NULL.
CREATE TABLE sales (region STRING, id INT)
WITH ROW FILTER us_filter ON (region);The order of removal matters. If you drop the function while a table still references it, the table becomes inaccessible until someone runs ALTER TABLE <table_name> DROP ROW FILTER (or DROP MASK on the column). This per-table model is precise, but it doesn't scale. A hundred tables with SSN columns means a hundred SET MASK statements, and every new table needs another one before it is protected.
Checkpoint 1 of 8· Check yourself
Analysts must be able to query the customers table and see every row. For anyone outside HR, the ssn column should show '*--****' instead of the real value. What should you attach to the table?
A column mask takes the column value and returns either that value or a redacted version, so every row stays visible. A row filter only returns a boolean and would drop rows. Unity Catalog doesn't pass in a role, so the UDF has to check group membership itself.
“The UDF takes the column value as input and returns the original or a masked version.”Source: docs.databricks.com
2.Governed tags as trustworthy attributes
ABAC replaces per-table DDL with matching on attributes, and in Unity Catalog those attributes are governed tags. Ordinary Unity Catalog tags and comments describe data for discovery, and any user with APPLY TAG can set them. A governed tag is an account-level key with a tag policy. The policy limits the tag to a list of allowed values and controls who can assign it. That control is what makes a tag safe to enforce access with. If anyone could remove pii=ssn from a column, anyone could remove its mask.
-- Create a governed tag with allowed values.
CREATE GOVERNED TAG sensitivity_level VALUES ('low', 'medium', 'high');After a key is governed, only principals with the ASSIGN privilege on that governed tag can set or change its values. This also applies to assignments that existed before the tag was governed: creating a governed tag with an existing key brings every current assignment of that key under the new policy. Tags are defined at the account level, so a single taxonomy covers all workspaces and metastores in the account.
Tags are inherited downward, with one exception. A tag on a catalog or schema applies to every schema and table beneath it, and a lower-level object can override the inherited value. Columns are the exception: they never inherit, so a column mask policy only finds columns that carry the tag themselves. The policy functions has_tag() and has_tag_value() count inherited tags, which means a WHEN condition on a catalog-level tag matches every table in that catalog.
Checkpoint 2 of 8· Check yourself
Your team already has an ungoverned tag key department on dozens of tables, and anyone with APPLY TAG has been setting its values. An admin now runs CREATE GOVERNED TAG department with a list of allowed values. What happens to the department tags that are already on those tables?
When you create a governed tag with a key that is already in use, every existing assignment of that key comes under the tag policy right away. From then on, only principals with ASSIGN on the tag can set or change its values. Nothing has to be reassigned.
“all existing tag assignments with that key automatically become governed. This lets you add governance to tags already in use.”Source: docs.databricks.com
3.Anatomy of a row filter or column mask policy
CREATE POLICY combines four things: a scope, the principals it applies to, a UDF, and tag conditions that pick out the tables and columns. To create one you need MANAGE on the securable the policy attaches to, or ownership of it, plus EXECUTE on the UDF. The compute must be Databricks Runtime 16.4 or above, or serverless.
| Clause | What it does |
|---|---|
| ON { METASTORE | CATALOG | SCHEMA | TABLE } | Scope: the policy evaluates against all tables, including views, below this object |
| TO ... EXCEPT ... | Principals the policy applies to, and those exempt who see unmodified data |
| WHEN condition | Table-level tag test using has_tag / has_tag_value; defaults to TRUE if omitted |
| MATCH COLUMNS condition AS alias | Finds tagged columns and names them; up to six for a row filter, three for a mask; all must match |
| ON COLUMN alias | Column mask only: which matched column is masked |
| USING COLUMNS (...) | UDF arguments: column aliases or constant literals, in the order the function expects |
The clauses have to line up with the function's signature. In a row filter policy, every UDF parameter comes from USING COLUMNS. Below, filter_by_region(region, allowed) receives the column matched as rgn and the literal 'EMEA'. Because the policy is attached to the sales catalog, every table there with a column tagged region is filtered for the EMEA team.
CREATE FUNCTION filter_by_region(region STRING, allowed STRING) RETURNS BOOLEAN
RETURN region = allowed;
CREATE POLICY regional_access_emea
ON CATALOG sales
ROW FILTER filter_by_region
TO `emea team`
FOR TABLES
MATCH COLUMNS has_tag('region') AS rgn
USING COLUMNS (rgn, 'EMEA');Column masks fill parameters differently. The column named in ON COLUMN is always passed as the first argument, and USING COLUMNS supplies only the parameters after it. That's why the policy below lists only (4) for a two-parameter function. The function's return type must match the target column's type or be castable to it.
CREATE FUNCTION mask_ssn(ssn STRING, show_last INT) RETURNS STRING
RETURN CONCAT('***-**-', RIGHT(ssn, show_last));
CREATE POLICY mask_ssn_columns
ON CATALOG hr_catalog
COLUMN MASK mask_ssn
TO `account users` EXCEPT `compliance team`
FOR TABLES
MATCH COLUMNS has_tag_value('pii', 'ssn') AS ssn_col
ON COLUMN ssn_col
USING COLUMNS (4);The two examples also show where the identity check moves. In a table-level mask, is_account_group_member() sits inside the function. In a policy, TO and EXCEPT decide who is affected, so the UDF can be a plain transformation that works for any group. WHEN narrows the policy by table tags and MATCH COLUMNS narrows it by column tags. For example, WHEN has_tag_value('sensitivity','restricted') limits a catalog-level filter to restricted tables, whether they exist today or are created next quarter. Databricks recommends attaching policies at the highest level that makes sense, which is usually the catalog.
Checkpoint 3 of 8· Fill the gap
The mask_ssn function below takes two parameters: the SSN and how many trailing digits to show. What goes in the USING COLUMNS clause so that this policy masks every column tagged pii=ssn?
CREATE FUNCTION mask_ssn(ssn STRING, show_last INT) RETURNS STRING
RETURN CONCAT('***-**-', RIGHT(ssn, show_last));
CREATE POLICY mask_ssn_columns
ON CATALOG hr_catalog
COLUMN MASK mask_ssn
TO `account users` EXCEPT `compliance team`
FOR TABLES
MATCH COLUMNS has_tag_value('pii', 'ssn') AS ssn_col
ON COLUMN ssn_col
USING COLUMNS ( ? );In a column mask policy, the column named in ON COLUMN (ssn_col) always fills the UDF's first parameter. USING COLUMNS supplies only the parameters after it, which here is just the literal 4 for show_last.
Source: docs.databricks.comCheckpoint 4 of 8· Exam question
A Databricks Unity Catalog metastore has been tagged so that every catalog, schema, and table where compliance officers store customer records carries the governed tag sensitivity=restricted. The data platform team needs any table under that tag — including tables created next quarter — to automatically show only rows belonging to the querying user's assigned region, without editing each table's DDL as new tables appear. Which approach satisfies this requirement with the least ongoing maintenance?
Correct answer: A — Attach one ABAC policy at the catalog level with ROW FILTER and a WHEN has_tag_value('sensitivity','restricted') clause, so it reaches every current and future table carrying that tag automatically.
- A. A catalog-level ABAC policy that keys off
has_tag_value('sensitivity','restricted')is the correct fit because a single policy definition automatically extends to new tables that acquire the tag, with no per-table DDL required. - B. Manually creating a UDF and running
ALTER TABLE ... SET ROW FILTERprotects only the tables it is explicitly applied to; it does not extend to any table created after this run, so the team would have to repeat the step indefinitely. - C. A dynamic view adds a filtering layer only in front of the specific view definitions that were built, and it does not retroactively or automatically protect base tables or any table created later, so it does not meet the automatic-scaling requirement.
- D. Splitting data across separate per-region catalogs replaces row-level filtering with physical partitioning of storage, which does not scale automatically to newly tagged tables and requires re-architecting data placement rather than applying a governance policy.
Checkpoint 5 of 8· Exam question
A Unity Catalog admin tags every column that stores a customer's government ID number with the governed tag pii=true across several schemas in the finance catalog. Security wants any column carrying that tag to be masked to show only the last four digits for everyone except the compliance_officers group, and wants newly created columns tagged the same way to be masked automatically without rewriting the policy. Which action meets this goal?
Correct answer: A — Create an ABAC column mask policy scoped to the catalog using MATCH COLUMNS has_tag_value('pii','true') AS id_col ON COLUMN id_col, so every matching column is masked automatically as it is tagged.
- A. A column-scoped ABAC policy built with
MATCH COLUMNSandhas_tag_value('pii','true')masks every column carrying that tag today and automatically covers any column tagged the same way afterward, which is exactly the catalog-wide, self-extending behavior requested. - B. A manually attached masking UDF via
ALTER TABLE ... ALTER COLUMN ... SET MASKonly covers the specific column it was applied to, so the admin would have to repeat the same statement by hand for every newly tagged column instead of it happening automatically. - C. A view-based workaround only reshapes the query surface for whoever queries the view; it does not stop anyone from bypassing the mask by querying the base table directly, and it still needs to be rebuilt for each new table.
- D. Building narrower per-group views that drop the ID column entirely removes the field for those groups instead of masking it, and it still requires a new view definition each time a column is newly tagged, so it does not scale automatically.
4.Choosing ABAC or table-level controls, and what policies can target
| Situation | Better fit |
|---|---|
| Consistent rules across many tables, schemas or catalogs | ABAC policy |
| Growing estate where new tables should be covered once tagged | ABAC policy |
| Policy authors and data stewards are separate teams | ABAC policy |
| Logic specific to one table that doesn't generalize | Table-level SET ROW FILTER / SET MASK |
| Small, stable set of tables managed by their owners | Table-level SET ROW FILTER / SET MASK |
ABAC policies and table-level controls can apply to the same table, but only if they don't conflict. For a given user, a table can have one distinct row filter, and each column can resolve to one distinct mask. Databricks detects a conflict by comparing the functions involved, not their output. If an ABAC policy and a table-level mask both use the same function, the query runs. If they use two different functions, the query is blocked with an error, even when both functions would return the same data.
Row filter and column mask policies only target tables. That includes streaming tables, materialized views and, in Beta, views, all selected with FOR TABLES. They can't be attached to volumes or registered models. ABAC has two other policy types, and neither uses a UDF:
- GRANT policies grant a privilege when an object's tags match. The effective privileges are the union of direct grants and policy grants, so a GRANT policy can't remove access that a direct
GRANTgave. - DENY policies (Beta) currently cover only the MANAGE ACCESS CONTROL privilege, and for that privilege a DENY overrides any grant.
- Row filter and column mask policies filter rows and mask values at query time, and they are the only types that need a UDF.
Checkpoint 6 of 8· Match them up
A governance team is choosing among the four ABAC policy types. Match each type to how it works.
Tap a term, then the definition that fits it.
Only row filter and column mask policies use a UDF, and they change what a query returns. GRANT and DENY policies change privileges when tags match. GRANT only adds access. DENY currently covers only MANAGE ACCESS CONTROL.
“GRANT and DENY policies don't use UDFs, and instead grant or deny privileges when their tag-based condition matches the target object's attributes.”Source: docs.databricks.com
Checkpoint 7 of 8· Exam question
An engineering team is evaluating how attribute-based access control (ABAC) governed tags and policies behave across a Unity Catalog metastore before rolling them out broadly. Which of the following statements are accurate? (Select all that apply.)(Select 3)
Correct answers: A, B, C — A single ABAC policy attached at the catalog level automatically extends to new tables created later in that catalog, as long as those tables carry the tag the policy's WHEN clause matches.; Governed tags applied at the catalog level propagate down to schemas and tables beneath it, so a lower-level object inherits the tag unless a more specific tag overrides it closer to the object.; A tag applied to a table does not automatically apply to that table's columns, so column-level ABAC policies require the columns themselves to carry a matching tag.
- A. This statement is accurate: attaching a policy at the catalog level lets it apply automatically to any table that later acquires the matching tag, which is the core scaling benefit of ABAC over manually attaching filters table by table.
- B. This statement is accurate: tags follow the catalog-to-schema-to-table hierarchy by default, so an object inherits a tag from its parent unless a more specific tag is set closer to that object.
- C. This statement is accurate: tags do not flow from a table down to its columns, so a column-level policy condition only matches columns that have been tagged directly, even if the parent table carries a matching tag.
- D. This statement is inaccurate: ABAC GRANT policies only add privileges when their tag condition is met, and documentation is explicit that they cannot revoke access a principal already holds through a direct grant made outside the policy.
- E. This statement is inaccurate: DENY policies are currently limited in scope to the
MANAGE ACCESS CONTROLprivilege, so they do not universally override every GRANT regardless of which privilege is involved. - F. This statement is inaccurate: row filter and column mask policies apply to table-level securables such as tables, materialized views, and streaming tables, not to volumes or registered models.
5.Query-time evaluation and the fail-closed model
Policies are evaluated on every query, for the user who runs it. For each table in the query, Unity Catalog finds the policies whose scope covers the table and checks whether the user is in TO and not in EXCEPT. It then tests the tag conditions, including inherited tags, and passes the resulting filter or mask to the Databricks Runtime. The runtime enforces it as a secure view over the table scan, the same mechanism table-level filters use. When a query goes through a view, access to the underlying tables is checked against the view owner, but policies are still evaluated for the user running the query. A change to someone's group membership, or to a tag, changes what they see on their next query.
ABAC fails closed: when Databricks can't confirm that every applicable policy is enforced, it denies access. Deleting a governed tag that a policy references makes every query in that policy's scope fail with UC_ABAC_UNKNOWN_TAG_POLICY, even on tables that never had the tag. The UI and the API both allow the deletion, so check for policy references before you delete a tag. A deleted UDF fails in the same way with UC_DEPENDENCY_DOES_NOT_EXIST. Clients running Databricks Runtime below 16.4 are refused. On dedicated access mode, enforcement is handed off to serverless compute.
Some operations can't run with filters or masks applied, so they fail instead of skipping enforcement. These include deep and shallow clones, OpenSharing from the share owner, and AI Search index syncs. The principal running them has to be listed in EXCEPT on every policy that applies to the table. Tags can also block pipelines: you can't drop a column that has a governed tag. A user with ASSIGN on the tag must remove it, let the schema change run, and then reapply it.
Checkpoint 8 of 8· Check yourself
A nightly job deep-clones a table in a catalog that has a column mask policy. The job's service principal is in the policy's TO list. What happens when the job runs, and how do you make it work?
ABAC fails closed. Operations that can't run with filters or masks applied, such as deep and shallow clones, fail instead of skipping enforcement, and they only run for a principal that is exempt through EXCEPT. Compute on Runtime below 16.4 is also refused, so it doesn't get around the policy.
“To run them, the principal must be listed in the EXCEPT clause of every ABAC policy that applies to the table.”Source: docs.databricks.com
Sources7
Sources
(7)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://docs.databricks.com/aws/en/data-governance/unity-catalog/filters-and-masks/manually-applyOfficial docs
“UDF parameter types must match the data types of the columns passed to them.”
↩︎ Row filters and column masks on a single table“ALTER TABLE <table_name> ALTER COLUMN <col_name> SET MASK <mask_func_name> USING COLUMNS <additional_columns>;”
↩︎ Row filters and column masks on a single table“You must perform the ALTER TABLE ... DROP ROW FILTER command before you drop the function.”
↩︎ Row filters and column masks on a single table - 2.
“Rows where the UDF returns FALSE are excluded from query results.”
↩︎ Row filters and column masks on a single table“A row filter policy can include up to six MATCH COLUMNS expressions, and a column mask policy can include up to three.”
↩︎ Anatomy of a row filter or column mask policy“and EXECUTE on the UDF that implements the filtering or masking logic”
↩︎ Anatomy of a row filter or column mask policy“The UDF takes the column value as input and returns the original or a masked version.”
↩︎ Checkpoint - 3.
“only users with the appropriate permissions can assign values to that tag, and only from a predefined set of allowed values”
↩︎ Governed tags as trustworthy attributes“all existing tag assignments with that key automatically become governed. This lets you add governance to tags already in use.”
↩︎ Checkpoint - 4.
“only users with the ASSIGN privilege on the department governed tag can assign or modify department tag values.”
↩︎ Governed tags as trustworthy attributes - 5.
“You can override inherited tags at every level except the column level”
↩︎ Governed tags as trustworthy attributes“Databricks recommends attaching policies at the highest applicable level, usually the catalog, to maximize governance efficiency.”
↩︎ Anatomy of a row filter or column mask policy“Tables, including streaming tables, materialized views, and views (Beta), are the supported securable type for row filter and column mask policies”
↩︎ Choosing ABAC or table-level controls, and what policies can target“As new data objects are created and tagged, the policy applies automatically without requiring separate policy definitions for each object.”
↩︎ Key concept“column tags do not inherit from the parent table and must be applied directly.”
↩︎ Exam trap 1“GRANT policies only add access. They cannot revoke access that was granted directly.”
↩︎ Exam trap 2“currently scoped to the MANAGE ACCESS CONTROL privilege. A DENY policy always takes precedence over any grant.”
↩︎ Exam trap 3“The masked column value is bound automatically as the first argument from the ON COLUMN clause”
↩︎ Exam trap 4“column tags do not inherit from the parent table and must be applied directly.”
↩︎ Prediction“GRANT and DENY policies don't use UDFs, and instead grant or deny privileges when their tag-based condition matches the target object's attributes.”
↩︎ Checkpoint - 6.
“If they apply different functions, Databricks blocks access and returns an error”
↩︎ Choosing ABAC or table-level controls, and what policies can target“Only one distinct row filter can apply.”
↩︎ Choosing ABAC or table-level controls, and what policies can target - 7.https://docs.databricks.com/aws/en/data-governance/unity-catalog/abac/policy-evaluationOfficial docs
“ABAC follows a fail-closed model, where Databricks defaults to denying access if it cannot verify security.”
↩︎ Query-time evaluation and the fail-closed model“Changes to group membership or tag assignments dynamically alter the effective policies at query time.”
↩︎ Query-time evaluation and the fail-closed model“To run them, the principal must be listed in the EXCEPT clause of every ABAC policy that applies to the table.”
↩︎ Query-time evaluation and the fail-closed model“Databricks prevents deleting a column that has a governed tag applied.”
↩︎ Query-time evaluation and the fail-closed model“queries against tables in that scope fail with UC_DEPENDENCY_DOES_NOT_EXIST”
↩︎ Query-time evaluation and the fail-closed model“This occurs even if the tag was not applied to the queried tables.”
↩︎ Exam trap 5