Sub topic 12
Limiting catalogs to specific workspaces
This chapter assumes you know the Unity Catalog hierarchy (metastore, catalog, schema, table), how GRANT works, and how groups are used as principals.
Why bind a catalog to workspaces
A metastore can be attached to many workspaces. By default, a catalog is available from every one of them. Anyone who holds privileges on the catalog can use it from any attached workspace.
That default is a problem when you separate environments. A prod catalog that users can open from the development workspace makes accidental writes more likely. A catalog with regulated data should be reachable only from a workspace with stricter controls.
A workspace binding limits a catalog to a chosen list of workspaces. Once a catalog is bound, it is invisible and unusable from every other workspace, whatever privileges a user holds.
Bindings and privileges are separate checks
A binding does not give anyone access. It only decides where the catalog can be used. Privileges decide who can use it. A user needs both.
Suppose data-analysts holds these grants:
GRANT USE CATALOG ON CATALOG main TO `data-analysts`;
GRANT USE SCHEMA ON SCHEMA main.sales TO `data-analysts`;
GRANT SELECT ON TABLE main.sales.orders TO `data-analysts`;If main is bound only to the production workspace, these analysts can query main.sales.orders there. In any other workspace the catalog does not appear, even though the grants still exist.
Configuring a binding
Workspace bindings are managed in Catalog Explorer, or through the Unity Catalog workspace bindings API for automation.
- Open the catalog in Catalog Explorer and go to the Workspaces tab.
- Turn off the option that lets all workspaces access the catalog.
- Select Assign to workspaces and pick the workspaces that should have access.
- Choose an access level for each workspace.
Each binding is either read and write or read-only. A read-only binding lets a workspace query the catalog but not change it. This suits a development workspace that needs to read production data.
Only a metastore admin or the catalog owner can change bindings. A workspace admin cannot override them, because bindings are set at the metastore level.
Bindings also apply to storage credentials and external locations. You can restrict those to specific workspaces in the same way.
Common errors
- Assuming a binding grants access. Users in a bound workspace still need
USE CATALOGand the other privileges. - Binding to the wrong workspace. If you remove a workspace from the list, users there lose access to the catalog immediately. Check the list before saving.
- Missing catalog in a workspace. Before you debug grants, check the Workspaces tab. A catalog that is not bound to the current workspace is hidden, not just locked.
- Using a binding as the only control. A binding limits where data is reachable. It does not limit who can reach it within that workspace. Combine it with group-based grants.
Exercise
A group holds USE CATALOG, USE SCHEMA and SELECT on a table in catalog finance. The catalog is bound only to the prod workspace. A group member opens the dev workspace and cannot see finance. What explains this, and what must change to allow read access from dev?
Show answer
The workspace binding is the cause. finance is not bound to dev, so it is hidden there even though the grants are correct. A metastore admin or the catalog owner must add dev to the catalog's workspace list. A read-only binding is enough for read access, and the existing grants then apply.