Sub topic 6
Granting the privileges models need
This chapter assumes you can log and register a model in Unity Catalog, and that you know catalogs, schemas and tables. Here you will see which privileges a registered model needs, who needs them, and how to fix the errors that appear when one is missing.
Why models need explicit privileges
A registered model is a securable object in Unity Catalog, like a table. It lives inside a schema, which lives inside a catalog. Access is checked at each level, so having a privilege on the model alone is not enough. A user must also be able to reach the catalog and schema that contain it.
The three privileges for using a model
To load a model or serve it, a principal (a user, service principal or group) needs three privileges:
| Level | Privilege | What it allows |
|---|---|---|
| Catalog | USE CATALOG | See and reach objects in the catalog |
| Schema | USE SCHEMA | See and reach objects in the schema |
| Model | EXECUTE | Load the model and call it for predictions |
Grant them with SQL. Using a group is easier to maintain than granting to individual users.
GRANT USE CATALOG ON CATALOG main TO `data-scientists`;
GRANT USE SCHEMA ON SCHEMA main.default TO `data-scientists`;
GRANT EXECUTE ON MODEL main.default.iris_classifier TO `data-scientists`;After these statements, anyone in data-scientists can load main.default.iris_classifier and use its versions and aliases.
Privileges for creating models
Granting use is different from granting the right to create. To register a new model, a principal needs these on the schema:
- USE CATALOG on the parent catalog.
- USE SCHEMA on the parent schema.
- CREATE MODEL on the schema.
Registering a new version of an existing model requires you to own that model, or to have the privileges that let you modify it. Ownership matters here. The principal that creates a model becomes its owner, and owners can grant privileges on it to others.
GRANT CREATE MODEL ON SCHEMA main.default TO `ml-engineers`;Privileges and serving
An endpoint runs your model under an identity. Two checks matter:
- The person who creates the endpoint must have EXECUTE on the model, plus USE CATALOG and USE SCHEMA on its parents.
- The endpoint itself must be able to read the model at runtime. Databricks handles this for the endpoint's owner, but if the owner loses access, the endpoint can fail to update or start.
Clients that only query the endpoint do not need EXECUTE on the model. They need permission on the endpoint itself, which is covered in the chapter on authentication.
Checking and revoking grants
Use SHOW GRANTS to see what is in place, and REVOKE to remove access.
SHOW GRANTS ON MODEL main.default.iris_classifier;
REVOKE EXECUTE ON MODEL main.default.iris_classifier FROM `data-scientists`;Privileges are inherited. If you grant EXECUTE on a schema, the principal gets it on every model in that schema, including models created later. Granting at the model level is narrower and safer when a schema holds models with different audiences.
Common errors
- The model cannot be found, or "does not exist". Unity Catalog often hides objects you cannot see. Missing USE CATALOG or USE SCHEMA usually looks like a missing model, not a permission error. Check the parent privileges first.
- Permission denied when loading a model. The principal has the parents but not EXECUTE on the model.
- Permission denied when registering. The principal lacks CREATE MODEL on the schema.
- Grants work for you but not for a job. A job runs as its own identity, often a service principal. Grant privileges to that identity, not to your own user.
Exercise
A teammate in the group analysts reports that models:/main.default.iris_classifier@champion fails with "model does not exist", although you can see the model. You have already granted EXECUTE on the model to analysts. What is the most likely missing privilege, and what statements fix it?
Show answer
They probably lack USE CATALOG on main or USE SCHEMA on main.default, so the model is hidden from them. Run GRANT USE CATALOG ON CATALOG main TO analysts; and GRANT USE SCHEMA ON SCHEMA main.default TO analysts;.
Exercise
Which privilege lets a principal register a brand-new model in the schema main.default, and on which object is it granted?
Show answer
CREATE MODEL, granted on the schema main.default. The principal also needs USE CATALOG on main and USE SCHEMA on main.default.