CertSafari
    Databricks Certified Data Engineer Professional - October 9 onwards· Lessons

    Domain 6 · Lesson 34/45

    ABAC policies with governed tags for row filters and column masks

    Apply attribute-based access control (ABAC) policies with governed tags to enforce row filters and column masks at scale.

    17 min read
    1.6% of exam
    7 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    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:

    A column mask UDF that branches on group membershipsql
    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.

    Declaring a row filter at table creationsql
    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?

    Sources12

    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.

    Creating a governed tag with a fixed set of allowed valuessql
    -- 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?

    Sources345

    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.

    CREATE POLICY clauses and what each controls
    ClauseWhat 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 conditionTable-level tag test using has_tag / has_tag_value; defaults to TRUE if omitted
    MATCH COLUMNS condition AS aliasFinds tagged columns and names them; up to six for a row filter, three for a mask; all must match
    ON COLUMN aliasColumn 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.

    A catalog-wide row filter policy bound to a tagged columnsql
    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.

    A catalog-wide column mask policy: ssn_col fills the first parameter, 4 fills the secondsql
    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 ( ? );

    Checkpoint 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?

    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?

    Sources25

    4.Choosing ABAC or table-level controls, and what policies can target

    When each approach wins
    SituationBetter fit
    Consistent rules across many tables, schemas or catalogsABAC policy
    Growing estate where new tables should be covered once taggedABAC policy
    Policy authors and data stewards are separate teamsABAC policy
    Logic specific to one table that doesn't generalizeTable-level SET ROW FILTER / SET MASK
    Small, stable set of tables managed by their ownersTable-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 GRANT gave.
    • 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.

    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)

    0 of 3 selected

    Sources65

    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?

    Sources7

    Sources

    (7)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “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. 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. 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. 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. 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. 7.
      “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

    Spotted a mistake, or was something unclear? Tell us.