Sub topic 12
Storage credentials, external locations, and managed storage
This chapter explains how Unity Catalog controls access to cloud object storage. It assumes you can write basic SQL, know that tables are stored as files in cloud storage, and have read the chapters on managed and external tables and on privileges. The goal is to see which objects sit between a table and its files, who can use them, and where managed data ends up.
Why storage needs its own access control
Privileges on tables control who can run queries. They do not control who can read the files underneath. If a user could read the files directly in the bucket, a SELECT privilege would mean nothing.
Unity Catalog solves this by keeping cloud credentials out of users' hands. Users do not receive keys for the bucket. Instead, Unity Catalog holds a credential, checks the user's privileges, and then reads or writes the files on the user's behalf.
Three kinds of objects take part in this:
- A storage credential is a securable object that wraps a cloud identity, such as an AWS IAM role, that has access to storage.
- An external location is a securable object that pairs a cloud storage path with a storage credential.
- Managed storage is a location that Unity Catalog uses on its own to store the data of managed tables.
Storage credentials
A storage credential holds the identity that Unity Catalog uses to reach storage. On AWS this is an IAM role. On Azure it is a managed identity or service principal, and on Google Cloud it is a service account. The credential holds no data and has no path of its own. It only answers the question "which identity do we use?"
Key points:
- A credential is created by a user with the right privilege on the metastore, usually an administrator.
- The cloud identity must already trust Unity Catalog and have permission on the target storage. If that trust is wrong, every use of the credential fails.
- A credential can back many external locations.
- The credential is itself a securable object. Users need privileges on it only if they use it directly. Most users never touch it.
External locations
An external location ties one storage path to one storage credential. It is how an administrator says "this path may be used, with this identity."
The path is a URL such as s3://example-bucket/raw. The location covers that path and everything below it.
You normally create an external location in Catalog Explorer, with the API, or with Terraform. The SQL form looks like this:
CREATE EXTERNAL LOCATION IF NOT EXISTS raw_zone
URL 's3://example-bucket/raw'
WITH (STORAGE CREDENTIAL raw_access_role)
COMMENT 'Landing area for raw files';Once the location exists, privileges on it decide who may use that path. The main ones are:
| Privilege | What it allows |
|---|---|
| `READ FILES` | Read files directly from the path |
| `WRITE FILES` | Write files directly to the path |
| `CREATE EXTERNAL TABLE` | Create an external table whose path is under the location |
| `CREATE MANAGED STORAGE` | Use the location as managed storage for a catalog or schema |
You grant these like any other privilege:
GRANT CREATE EXTERNAL TABLE ON EXTERNAL LOCATION raw_zone TO `data-engineers`;
GRANT READ FILES ON EXTERNAL LOCATION raw_zone TO `data-engineers`;Creating an external table
An external table needs a path that an external location covers. The user also needs CREATE EXTERNAL TABLE on that location, plus the usual USE CATALOG, USE SCHEMA, and CREATE TABLE privileges on the parents.
CREATE TABLE dev.sales.raw_orders (
order_id BIGINT,
payload STRING
)
LOCATION 's3://example-bucket/raw/orders';The bucket name is a placeholder. This statement fails in these cases:
- No external location covers the path.
- The user lacks
CREATE EXTERNAL TABLEon the covering location. - The path overlaps a managed storage location or another table's path.
Overlap rules
Unity Catalog does not allow two external locations to cover the same path, and it does not allow a table path to sit inside another table's path. The rules exist so that one set of files is never governed by two conflicting sets of privileges.
Nested locations are a related case. If you register s3://example-bucket/raw and later register s3://example-bucket/raw/orders, the second overlaps the first. Plan your paths before you register them, because moving files later is costly.
The path-based access flow
The following diagram shows what happens when a user creates an external table.
The user never sees the credential. The privilege on the external location is the only gate.
Managed storage
Managed tables do not name a path. Unity Catalog chooses one inside a managed storage location. The location it picks depends on a lookup that goes from the most specific level to the least specific:
- The schema's managed location, if one was set.
- The catalog's managed location, if one was set.
- The metastore's managed location, if one was set.
The first one found wins. Newer metastores often have no metastore-level location, which means every catalog needs its own. When none of the three levels has a location, creating a managed table fails with an error that says no managed storage is configured.
You set a managed location when you create the catalog or schema:
CREATE CATALOG IF NOT EXISTS prod
MANAGED LOCATION 's3://example-bucket/prod-catalog';
CREATE SCHEMA IF NOT EXISTS prod.finance
MANAGED LOCATION 's3://example-bucket/prod-finance';The path must be covered by an external location, and the user needs CREATE MANAGED STORAGE on it. The bucket names above are placeholders.
What users cannot do with managed paths
Files for managed tables live in directories with generated names. You should not read or write them by path. Access goes through the table name, and the privileges on the table decide who gets in. This is what lets Unity Catalog manage the file layout, clean up files after a DROP TABLE, and optimize storage without breaking readers.
Dropping a managed table also removes its data after a retention period. Dropping an external table removes only the metadata and leaves the files in place.
Comparing the three storage objects
| Object | Holds | Created by | Used for |
|---|---|---|---|
| Storage credential | A cloud identity | Administrator | Reaching storage |
| External location | A path plus a credential | Administrator | Governing external tables and file access |
| Managed location | A path set on a metastore, catalog, or schema | Administrator or catalog owner | Storing managed tables |
Common errors and how to read them
- No external location covers the path. The path is wrong, or no one registered the location. Check with
SHOW EXTERNAL LOCATIONSand compare the URLs. - Permission denied on the location. You hold privileges on the table parents but not
CREATE EXTERNAL TABLEon the location. Ask the location's owner. - The credential cannot reach the path. The location exists, but the cloud identity lacks permission on the bucket, or its trust policy does not allow Unity Catalog. Fix this in the cloud account, not in SQL.
- Overlap errors. Your new location or table path sits inside or around an existing one. List existing locations and choose a path that does not intersect.
- No managed storage configured. Set a managed location on the catalog, or on the schema.
Use these commands to inspect what exists:
SHOW STORAGE CREDENTIALS;
SHOW EXTERNAL LOCATIONS;
DESCRIBE EXTERNAL LOCATION raw_zone;
SHOW GRANTS ON EXTERNAL LOCATION raw_zone;Design guidance
- Give each environment or business domain its own managed location, so data from different catalogs is separated in storage as well as in names.
- Use external tables when other tools must read the same files, or when the data exists before Unity Catalog manages it.
- Use managed tables for everything else, so Unity Catalog can handle layout and cleanup.
- Reserve file-level privileges for engineers who run ingestion jobs.
Exercise
A user holds USE CATALOG, USE SCHEMA, and CREATE TABLE on dev.sales. An external location covers s3://example-bucket/raw, and the user has no privileges on it. The user runs CREATE TABLE dev.sales.raworders (orderid BIGINT) LOCATION 's3://example-bucket/raw/orders'. What happens, and what single grant fixes it?
Show answer
The statement fails because the user lacks CREATE EXTERNAL TABLE on the covering external location. Granting CREATE EXTERNAL TABLE on that external location to the user (or one of their groups) lets the statement succeed, assuming the storage credential can reach the path.
Exercise
A catalog was created without a managed location, the schema inside it has none, and the metastore has no metastore-level location. What happens when a user creates a managed table in that schema, and how can you fix it?
Show answer
The statement fails because no managed storage is configured at the schema, catalog, or metastore level. Fix it by setting a managed location on the schema or catalog, using a path covered by an external location on which you hold CREATE MANAGED STORAGE.