Preparing Your Databricks Account
ALTR connects to your Databricks workspace as a service principal, and applies tag-based masking to Unity Catalog columns using native column masks (AWS | Azure).
Overview
Section titled “Overview”- Create the required groups.
- Create the ALTR service principal.
- Set the Metastore admin group and grant the ALTR service group read access to your catalogs.
- Configure the workspace.
- Configure a SQL warehouse.
- Allow network access, if IP access lists or context-based ingress controls protect your workspace.
- Configure a workspace cluster (optional).
Requirements
Section titled “Requirements”ALTR supports Databricks Premium Tier on AWS and on Azure, in serverless workspaces and classic workspaces, with Unity Catalog enabled. Classic workspaces require a Metastore-level managed storage location. Contact ALTR support about Hive Catalog or connecting Databricks on Google Cloud Platform (GCP).
ALTR uses the ALTR service principal to run a masking job that sets column masks and creates the catalog, tables, and user-defined functions (UDFs) ALTR needs. This job runs whenever you apply a tag-based masking policy to your Unity Catalog.
By default, ALTR runs the masking job as a serverless notebook job and runs automatic tagging on a SQL warehouse, so your workspace doesn’t need a cluster. In a classic workspace, you can instead run masking jobs and automatic tagging on an existing all-purpose cluster – see Configure a Workspace Cluster (Optional). Classification reads sample data through a SQL warehouse either way.
A classic workspace that runs ALTR’s masking jobs on serverless compute must be in a region that supports serverless compute (AWS | Azure).
This setup covers everything needed to run classification and data masking against Databricks. Both are separate, ALTR-side capabilities that don’t require additional Databricks-side configuration.
Prerequisites
Section titled “Prerequisites”Before you begin, confirm the following:
- You have a Databricks user with both account admin privilege (in the Databricks account portal, typically at
https://accounts.cloud.databricks.comon AWS orhttps://accounts.azuredatabricks.neton Azure) and workspace admin privilege on the workspace you want ALTR to connect to. - For a classic workspace, the Metastore you want ALTR to connect to has a Metastore-level managed storage location. If you already have a Metastore, see Databricks’ guide to configuring managed storage for an existing Metastore (AWS | Azure). If you’re creating a new Metastore, see Databricks’ guide to creating a Metastore (AWS | Azure).
Create a text file to record the following values as you work through this page – you’ll need them when you connect ALTR to your Databricks account:
Existing Metastore Admin Name:Metastore Admin Group Name:ALTR Service Principal Name:ALTR Service Principal ID:ALTR Service Principal OAuth Secret:Databricks Workspace Hostname:Databricks Workspace Cluster ID:Create the Required Groups
Section titled “Create the Required Groups”To create the groups ALTR needs:
- From the Databricks account portal, go to User management > Groups > Add group.
- Enter
altr-service-groupfor the Group name – this exact name is required. - Add another group and name it
Metastore-admins(or a name of your choosing). Record the name you chose in your text file as the Metastore Admin Group Name.
Create the ALTR Service Principal
Section titled “Create the ALTR Service Principal”The ALTR service principal is a machine-to-machine Databricks service principal ALTR uses to manage tag-based masking objects on Unity Catalog.
To create the service principal:
-
From the Databricks account portal, select User management > Service Principals > Add service principal.
-
Enter a name for the service principal (for example,
altr-service-principal). Record the name in your text file as the ALTR Service Principal Name. -
Click Add. You’re returned to User management > Service Principals when this completes.
-
Click the service principal you just created, then select the Credentials & secrets tab.
-
Under OAuth secrets, click Generate secret.
-
In Lifetime (days), enter a value from 1 to 730 that is consistent with your company’s security policies.
-
Under Scope, select Other APIs and confirm that
all-apisis listed. If it isn’t, add it from Add scope. ALTR currently requires theall-apisscope. -
Click Generate.
-
Copy the Secret and Client ID values shown, and record them in your text file as the ALTR Service Principal OAuth Secret and ALTR Service Principal ID. Databricks displays the secret only once; you cannot retrieve it after you close the dialog.
-
Go to Roles and enable Account Admin.
Set the Metastore Admin Group
Section titled “Set the Metastore Admin Group”The altr-service-group must be a Metastore admin to see all objects in Unity Catalog and manage their privileges. Since a Metastore can have only one Metastore admin, this step combines the ALTR service group and your existing Metastore admin, if any, into the Metastore-admins group created earlier, then sets that group as the Metastore admin.
To record your existing Metastore admin:
- From the Databricks account portal, select Catalog > (your Metastore).
- Record the value shown for Metastore Admin, if one is set, in your text file as the Existing Metastore Admin Name.
To add the ALTR service principal to the ALTR service group:
- Select User management > Groups.
- Click altr-service-group.
- Click Add members and add the ALTR service principal you created.
To add the ALTR service group, and any existing Metastore admin, to the Metastore-admins group:
- Return to User management > Groups.
- Click the
Metastore-adminsgroup you created. - Click Add members.
- Add
altr-service-groupand, if you recorded one, the existing Metastore admin. If you recorded none, also add the user who will run the grants in Grant Read Access to Your Catalogs.
To set Metastore-admins as the Metastore admin:
- Select Catalog and click the Metastore you want ALTR to connect to.
- Under Metastore Admin, click Edit.
- Set the
Metastore-adminsgroup as the Metastore admin.
Grant Read Access to Your Catalogs
Section titled “Grant Read Access to Your Catalogs”The altr-service-group needs USE CATALOG on each catalog, and USE SCHEMA and SELECT on each catalog or schema, that you want ALTR to classify and protect. Classification reads sample rows from each table and skips any schema the group can’t read. Masking also needs MODIFY on each table that ALTR masks. Being a Metastore admin lets the group manage privileges, but it doesn’t give the group access to data.
Grant these privileges to altr-service-group, not to the ALTR service principal. A grant on a catalog applies to every current and future schema and table in that catalog.
Run the grants in the SQL Editor of a workspace attached to the Metastore, as a Metastore admin (a member of the Metastore-admins group) or the catalog’s owner. The editor runs on a SQL warehouse; if the workspace has none yet, create one first, as described in Configure a SQL Warehouse.
To grant read and masking access on one catalog, run the following statement, replacing <CATALOG_NAME> with the catalog’s name:
GRANT USE CATALOG, USE SCHEMA, SELECT, MODIFY ON CATALOG `<CATALOG_NAME>` TO `altr-service-group`;To grant read and masking access on specific schemas only, grant USE CATALOG on the catalog and USE SCHEMA, SELECT, and MODIFY on each schema. The group can then read only the schemas you grant, and a schema created later needs its own grant before ALTR can classify it:
GRANT USE CATALOG ON CATALOG `<CATALOG_NAME>` TO `altr-service-group`;GRANT USE SCHEMA, SELECT, MODIFY ON SCHEMA `<CATALOG_NAME>`.`<SCHEMA_NAME>` TO `altr-service-group`;To grant read and masking access on many catalogs at once, use the altr_grant_read_access stored procedure. It tries the catalog-level grant on every catalog you can see, and when a catalog-level grant fails, it tries the grant on each schema in that catalog instead. It skips the system, samples, hive_metastore, and __databricks_internal catalogs, and lists only catalogs you can see. To cover every catalog, run it as a Metastore admin or the catalog’s owner for each catalog. The procedure requires Databricks SQL or Databricks Runtime 17.0 or above.
To grant read and masking access with the stored procedure:
-
Create the procedure by running the following statement, replacing
<CATALOG>.<SCHEMA>with a schema you can create a procedure in. Wrap the catalog or schema name in backticks if it contains special characters:CREATE OR REPLACE PROCEDURE <CATALOG>.<SCHEMA>.altr_grant_read_access(principal STRING DEFAULT 'altr-service-group',catalogs ARRAY<STRING> DEFAULT NULL)LANGUAGE SQLSQL SECURITY INVOKERAS BEGINDECLARE results ARRAY<STRUCT<securable_type STRING, securable_name STRING, status STRING, error STRING>>DEFAULT CAST(array() AS ARRAY<STRUCT<securable_type STRING, securable_name STRING, status STRING, error STRING>>);DECLARE grantee STRING DEFAULT '`' || replace(principal, '`', '``') || '`';DECLARE failed BOOLEAN;DECLARE catalog_failed BOOLEAN;DECLARE err STRING;FOR c ASSELECT catalog_nameFROM system.information_schema.catalogsWHERE catalog_name NOT IN ('system', 'samples', 'hive_metastore', '__databricks_internal')AND (catalogs IS NULL OR array_contains(catalogs, catalog_name))ORDER BY catalog_nameDOSET catalog_failed = false;BEGINDECLARE EXIT HANDLER FOR SQLEXCEPTIONBEGINGET DIAGNOSTICS CONDITION 1 err = MESSAGE_TEXT;SET catalog_failed = true;END;EXECUTE IMMEDIATE'GRANT USE CATALOG, USE SCHEMA, SELECT, MODIFY ON CATALOG `' || replace(c.catalog_name, '`', '``') || '` TO ' || grantee;END;SET results = array_append(results, named_struct('securable_type', 'CATALOG','securable_name', c.catalog_name,'status', IF(catalog_failed, 'FAILED', 'GRANTED'),'error', IF(catalog_failed, err, CAST(NULL AS STRING))));IF catalog_failed THENFOR s ASSELECT schema_nameFROM system.information_schema.schemataWHERE catalog_name = c.catalog_nameAND schema_name <> 'information_schema'ORDER BY schema_nameDOSET failed = false;BEGINDECLARE EXIT HANDLER FOR SQLEXCEPTIONBEGINGET DIAGNOSTICS CONDITION 1 err = MESSAGE_TEXT;SET failed = true;END;EXECUTE IMMEDIATE'GRANT USE SCHEMA, SELECT, MODIFY ON SCHEMA `' || replace(c.catalog_name, '`', '``') || '`.`'|| replace(s.schema_name, '`', '``') || '` TO ' || grantee;END;SET results = array_append(results, named_struct('securable_type', 'SCHEMA','securable_name', c.catalog_name || '.' || s.schema_name,'status', IF(failed, 'FAILED', 'GRANTED'),'error', IF(failed, err, CAST(NULL AS STRING))));END FOR;END IF;END FOR;SELECT r.* FROM (SELECT explode(results) AS r) ORDER BY r.status, r.securable_name;END; -
Call the procedure to grant read and masking access on every catalog you can see, replacing
<CATALOG>.<SCHEMA>with the schema you created it in, backticks included if you used them:CALL <CATALOG>.<SCHEMA>.altr_grant_read_access();To grant read and masking access on specific catalogs only, pass their names:
CALL <CATALOG>.<SCHEMA>.altr_grant_read_access(catalogs => array('<CATALOG_A>', '<CATALOG_B>'));The procedure returns one row per grant it attempted, with the
securable_type(CATALOGorSCHEMA),securable_name,status(GRANTEDorFAILED), anderrorfor each. -
Review the rows with a
FAILEDstatus. Each one names a catalog or schema for which a Metastore admin or the catalog’s owner must run the grant. A schema-level grant takes effect only once the group also hasUSE CATALOGon the parent catalog, so for aFAILEDcatalog row, that admin or owner must grant at leastUSE CATALOGon it, even when that catalog’s schema rows showGRANTED. Schema rows cover only the schemas that existed when the procedure ran, so to also cover schemas created later, have that admin or owner run the full catalog-level grant instead.
Configure the Workspace
Section titled “Configure the Workspace”The ALTR service group needs access to a workspace, with the Workspace access entitlement to run ALTR’s masking jobs and the Databricks SQL access entitlement to use a SQL warehouse. Add the group as a workspace admin: a workspace admin has both entitlements and permission on every SQL warehouse and cluster in the workspace, and it lets ALTR create the temporary workspace group it needs when it classifies a Metastore that already has ALTR tag-based masking policies.
To grant the ALTR service group access to a workspace:
- From the Databricks account portal, click Workspaces.
- Create or select a workspace for ALTR to connect to – it must be attached to the Metastore you want ALTR to connect to.
- Click the workspace name.
- Record the workspace URL (or hostname) in your text file as the Databricks Workspace Hostname.
- Click Permissions > Add permissions.
- Add
altr-service-groupas an Admin and click Save.
Configure a SQL Warehouse
Section titled “Configure a SQL Warehouse”ALTR reads sample data for classification through a SQL warehouse in your workspace, and on a connection with no cluster ID, it runs automatic tagging there too. Without a SQL warehouse in the workspace, classification can’t read sample data and automatic tagging fails. If you create one for ALTR, make it a serverless SQL warehouse (AWS | Azure).
ALTR picks the SQL warehouse automatically from the warehouses in the workspace, and prefers one that is already running.
To configure a SQL warehouse for ALTR:
- Log in to the workspace portal (using the hostname you recorded) as a user with admin privilege on that workspace.
- Click SQL Warehouses in the sidebar.
- If the workspace has no SQL warehouse for ALTR to use, create one:
- Click Create SQL warehouse.
- Enter a Name.
- Set Cluster Size to 2X-Small.
- Set Type to Serverless.
- Click Create. The warehouse starts automatically.
Allow Network Access
Section titled “Allow Network Access”If you restrict access to the workspace with IP access lists (AWS | Azure) or context-based ingress controls (AWS | Azure), they must allow ALTR’s requests. This applies to serverless and classic workspaces alike. Contact ALTR support for the current list of ALTR’s addresses.
Configure a Workspace Cluster (Optional)
Section titled “Configure a Workspace Cluster (Optional)”A workspace cluster is optional. Skip this section to run ALTR on serverless compute, which a serverless workspace requires. In a classic workspace, you can instead give ALTR the ID of an existing all-purpose cluster, and ALTR then runs its masking jobs and automatic tagging on that cluster.
To configure a workspace cluster for ALTR:
-
Log in to the workspace portal (using the hostname you recorded) as a user with admin privilege on that workspace.
-
Go to Compute.
-
Create or select an all-purpose compute cluster that runs Python 3.10 or newer and has Unity Catalog enabled.
-
Click the cluster’s name.
-
In the Configuration tab, scroll to Tags and expand Automatically added tags.
-
Record the value shown for ClusterId in your text file as the Databricks Workspace Cluster ID.
Connect Databricks to ALTR
Section titled “Connect Databricks to ALTR”With the values recorded in your text file – the service principal ID and OAuth secret, the workspace hostname, and the cluster ID if you configured one – you’re ready to connect the data source in ALTR. See Locate Your Databricks Connection Details if you need help finding any of these values again, and Manage Databricks Data Sources to connect the data source in the ALTR portal.