Skip to main content

Create and manage ABAC policies

This page describes how to create, edit, view, and delete ABAC policies in Unity Catalog. For an overview of policy concepts, see Core concepts for ABAC.

Requirements

All policy operations (create, edit, delete, show, describe) require MANAGE on the securable or object ownership. Creating a policy also requires:

  • Databricks Runtime 16.4 or above, or serverless compute. See Compute requirements.
  • For the filtering or masking logic, a user-defined function (UDF) in Unity Catalog that you have EXECUTE on, or a SQL function that you define inline when creating the policy.
  • Governed tags applied to target objects. See Governed tags.

Create a policy

You can create a policy using the Catalog Explorer UI, the CREATE POLICY SQL statement, or the Databricks REST APIs, SDKs, and Terraform.

To create a policy, you must have MANAGE on the securable where the policy is attached (catalog, schema, or table) or own the securable, and EXECUTE on the UDF that implements the filtering or masking logic.

  1. In your Databricks workspace, click Data icon. Catalog.

  2. Select the object that determines the policy scope, such as a catalog, schema, or table.

  3. Click the Policies tab.

  4. Click New policy.

  5. Complete the Policy identification section. The following table summarizes each field:

    Field

    Description

    Example

    Name

    A name for the policy. Must be unique among all policies defined on the same securable.

    hide_eu_customers, mask_ssn

    Description

    Optional. A description for the policy. Appears in audit logs and helps administrators understand policy intent.

    Restrict EU customer rows from US analysts, Mask SSN for all account users

  6. Complete the Principals and scope section. The following table summarizes each field:

    Field

    Description

    Example

    Applied to...

    The users, groups, or service principals subject to the policy. When these principals query tables in scope, the row filter or column mask is applied. To apply the policy to all principals in the account, select All account users.

    us_analysts, All account users

    Except for

    Principals exempt from the policy. Exempt principals are not subject to filtering or masking and see the full, unmodified data.

    admins, compliance_team

    Scope

    The securable where the policy is attached. The policy evaluates against all tables within the selected scope. Select a catalog, schema, or table. Databricks recommends attaching policies at the highest applicable level.

    Select catalog prod, then select schema customers.

    Table condition

    Determines which tables within the scope the policy applies to:

    • No condition: Applies the policy to all tables in scope.
    • Tables matching any of these tags: Specify a list of tag keys or tag key-value pairs. Tables that have any of these match the policy.
    • Tables matching a custom expression: Build a boolean expression using has_tag and has_tag_value, combined with AND, OR, and NOT for more complex matching logic. Tables where the expression evaluates to TRUE match the policy.

    If a table in scope does not match the condition, the policy does not apply to that table.

    Select Tables matching any of these tags, then choose tag key sensitivity with value high to restrict the policy to sensitive tables only.

    Example ABAC policy settings for the Principals and scope section.

  7. For Policy type, choose the type of access control to enforce:

    Option

    Description

    Use when

    Row filter

    Creates a row filter policy. The UDF evaluates each row and returns a boolean. Rows where the UDF returns FALSE are excluded from query results.

    Access depends on the values in each row, such as filtering by the values in a column that contains geographic regions.

    Column mask

    Creates a column mask policy. The UDF takes the column value as input and returns the original or a masked version. The return type must be castable to the target column's data type.

    You need to redact sensitive fields, such as SSNs, phone numbers, or email addresses, while still allowing the principal to query the table.

  8. The next few sections depend on your Policy type selection. Expand the section that matches your selection:

    Row filter

    In the Row filter function section, choose how to specify the row filter function:

    • Select existing: Select a UDF already defined in Unity Catalog. The UDF evaluates each row and returns a boolean. Rows where the function returns FALSE are excluded from query results. You must have EXECUTE on the UDF.
    • Create: Define a SQL function to use as the row filter logic.

    Example ABAC row filter policy settings for the Row filter function section.

    In the Function inputs section, provide a value for each function parameter. Each input can be a column matched by tags, a column matched by a custom expression, or a constant value.

    Example ABAC settings for the Function inputs section.

    Column mask

    In the Column conditions section, choose how to identify the columns to mask:

    • Columns matching any of these tags: Specify a list of tag keys or tag key-value pairs. Columns that have any of these are masked by the policy.
    • Columns matching a custom expression: Build a boolean expression using has_tag and has_tag_value, combined with AND, OR, and NOT for more complex matching logic. Columns where the expression evaluates to TRUE are masked.

    Example ABAC column mask policy settings for the Column conditions section.

    Then, choose the Masking function to apply to the matched columns:

    • Select existing: Select a UDF already defined in Unity Catalog. The UDF returns the original or masked value. The return type must be castable to the target column's data type. You must have EXECUTE on the UDF.
    • Create: Define a SQL function to use as the column masking logic.

    Example ABAC column mask policy settings for the Masking function section.

    In the Function inputs section, provide a value for each additional function parameter. Each input can be a column matched by tags, a column matched by a custom expression, or a constant value.

    This example uses a constant value of 4 to show the last 4 characters of the SSN.

    Example ABAC column mask policy settings for the Function inputs section.

  9. Click Create policy.

Edit a policy

  1. In your Databricks workspace, click Data icon. Catalog.
  2. Select the object the policy is attached to.
  3. Click the Policies tab.
  4. Select the policy you want to edit.
  5. Update any fields you want to change. You can modify the description, principals, policy type, conditions, and function input mappings. The policy name and the securable object where the policy is applied cannot be edited. For field descriptions, see Create a policy.
  6. Click Update policy.

Delete a policy

  1. In your Databricks workspace, click Data icon. Catalog.
  2. Select the object the policy is attached to.
  3. Click the Policies tab.
  4. Select the policy.
  5. Click Delete policy.

Show policies

Use SHOW POLICIES to list the policies defined on a securable. Use SHOW EFFECTIVE POLICIES to also include policies from parent scopes, such as catalog-level policies that affect a table.

SQL
SHOW [EFFECTIVE] POLICIES ON { CATALOG | SCHEMA | TABLE } securable_name

The result includes policy name, policy type, and the catalog, schema, or table where each policy is defined.

Viewing effective policies for a table does not require permissions on the parent catalog or schema. This allows a table admin to see the rules that apply without having read access to sibling tables' policies.

Example:

SQL
SHOW EFFECTIVE POLICIES ON SCHEMA prod.customers;

policy_name

policy_type

catalog

schema

comment

hide_eu_customers

ROW FILTER

prod

customers

mask_ssn

COLUMN MASK

prod

customers

Describe a policy

Use DESCRIBE POLICY to view the details of a specific policy. Requires MANAGE on the target securable or object ownership.

SQL
{ DESC | DESCRIBE } POLICY policy_name ON { CATALOG | SCHEMA | TABLE } securable_name

The result shows the policy's properties as key-value pairs, including name, securable type, securable name, principals, conditions, function name, and timestamps.

Example:

SQL
DESCRIBE POLICY hide_eu_customers ON SCHEMA prod.customers;

info_name

info_value

Name

hide_eu_customers

On Securable Type

SCHEMA

On Securable

prod.customers

To Principals

us_analysts

For Securable Type

TABLE

Match Columns

has_tag('geo_region') AS region

Policy Type

ROW_FILTER

Function Name

prod.customers.non_eu_region

Using Columns

region

Audit logging

Databricks logs governed tag and ABAC policy operations in the audit log system table. Below are example queries. For more information, see Audit logs.

SQL
-- All tag assignment and deletion events from the audit log
SELECT
event_time,
action_name,
user_identity.email AS actor,
request_params.workspace_id,
request_params.metastore_id,
request_params.tag_assignment,
response.status_code,
source_ip_address
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND action_name IN (
'createEntityTagAssignment',
'deleteEntityTagAssignment'
)
ORDER BY event_time DESC;

-- All ABAC policy CRUD operations
SELECT
event_time,
action_name,
user_identity.email AS actor,
request_params.name AS policy_name,
request_params.on_securable_type,
request_params.on_securable_fullname,
request_params.policy_info,
response.status_code
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND action_name IN ('createPolicy', 'deletePolicy', 'getPolicy', 'listPolicies')
ORDER BY event_time DESC;

More information