POST_START
Granting and Revoking Schema-Level Access
I recently had the task of managing access to a new data catalog in Databricks Unity Catalog. The goal was to grant specific permissions to a group of analysts while ensuring that only authorized users could interact with the data. I started by understanding the structure of the catalog and the schemas it contained.
I first needed to grant access to the `training` catalog at the catalog level. This would allow the analysts to navigate and use the entire catalog, but not yet access any specific schemas within it. I ran the following command:
GRANT USE CATALOG ON CATALOG training TO `analysts`;
Grant applied successfully; the principal now has the requested privilege.
I noticed that the grant was applied successfully, and the analysts now had the ability to use the `training` catalog. This was a good first step, as it allowed them to explore the catalog structure without accessing any sensitive data yet.
Next, I wanted to grant access to a specific schema within the `training` catalog. The schema in question was `training.sales`, and I needed to allow the analysts to use it. I executed the following command:
GRANT USE SCHEMA ON SCHEMA training.sales TO `analysts`;
Grant applied successfully; the principal now has the requested privilege.
I verified that the analysts now had access to the `training.sales` schema. This meant they could query the tables within it, which was exactly what I needed for their analysis.
To double-check the permissions, I ran the `SHOW GRANTS` command on the `training.sales` schema. This helped me confirm that the analysts had been granted the correct access, and also revealed that the `data_engineers` group had the `CREATE TABLE` privilege, which was intentional for their role.
SHOW GRANTS ON SCHEMA training.sales;
| principal | actionType | objectType |
|---|---|---|
| data_analysts | USE SCHEMA | SCHEMA |
| data_engineers | CREATE TABLE | SCHEMA |
I noticed that the `data_engineers` had a different privilege, which was expected and aligned with their responsibilities. This confirmed that the access controls were correctly configured.
Later, I realized that the analysts should no longer have access to the `training.sales` schema. Perhaps the project had changed, or the data was no longer needed for their work. I decided to revoke their access using the `REVOKE` command:
REVOKE USE SCHEMA ON SCHEMA training.sales FROM `analysts`;
Revoke applied successfully; the requested privilege is no longer granted.
I verified that the privilege had been successfully revoked. The analysts no longer had access to the schema, which was a crucial step in maintaining data security and compliance.
Throughout this process, I learned how important it is to carefully manage access at the schema level in Unity Catalog. By granting and revoking permissions precisely, I ensured that only the right people had access to the right data at the right time. This helped maintain both security and operational efficiency in our data environment.


Leave a Reply