Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Create a catalog based on requirements

A worked example

Put in order

Lakeside University uses one Unity Catalog metastore that is attached to two workspaces, ws-prod and ws-dev. The metastore has no default storage location configured.

  • Admin1 is authorized to create the required external location and grant privileges on it. No external location exists yet.
  • Engineer1 already has the CREATE CATALOG privilege on the metastore and has no privileges on any external location.

Engineer1 must create prod_catalog so that:

  • All managed tables and volumes in the catalog store their files under abfss://prod-data@stlakesideprod.dfs.core.windows.net/catalog-root.
  • ws-dev cannot access the catalog.

Statement Engineer1 will run (excerpt): CREATE CATALOG IF NOT EXISTS prod_catalog MANAGED LOCATION 'abfss://prod-data@stlakesideprod.dfs.core.windows.net/catalog-root' COMMENT 'Production catalog with dedicated ADLS Gen2 storage';

Which actions should Admin1 and Engineer1 perform, in order?

Your order

You didn't answer this one.

Correct order
1Admin1 creates an external location in Unity Catalog covering abfss://prod-data@stlakesideprod.dfs.core.windows.net/.
2Admin1 grants Engineer1 the CREATE MANAGED STORAGE privilege on the new external location.
3Engineer1 runs the CREATE CATALOG statement with the MANAGED LOCATION clause that points to the catalog-root subpath.
4Engineer1 configures the catalog's workspace bindings to restrict access to ws-prod.
Why

A catalog's managed location must be inside an external location that Unity Catalog already knows about, and the user creating the catalog needs CREATE MANAGED STORAGE on that location. The external location therefore has to be created first and the privilege granted second. Because this metastore has no default storage, Engineer1 must supply MANAGED LOCATION in the CREATE CATALOG statement itself; a subpath such as catalog-root inside the external location is allowed. Last, restrict the workspace bindings. By default, users with the required Unity Catalog privileges can access a new catalog from any attached workspace.

  • Step 1: Admin1 creates an external location in Unity Catalog covering abfss://prod-data@stlakesideprod.dfs.core.windows.net/. A managed storage location must sit in an external location that already exists, and none exists yet, so this comes first.
  • Step 2: Admin1 grants Engineer1 the CREATE MANAGED STORAGE privilege on the new external location. The privilege is granted on the external location, so the location must exist first.
  • Step 3: Engineer1 runs the CREATE CATALOG statement with the MANAGED LOCATION clause that points to the catalog-root subpath. Specifying managed storage requires CREATE MANAGED STORAGE on the external location, and because the metastore has no default storage, the location must be supplied at creation rather than later.
  • Step 4: Engineer1 configures the catalog's workspace bindings to restrict access to ws-prod. Bindings apply to an existing catalog and prevent access from ws-dev even for users who otherwise have the required Unity Catalog privileges.
  • Not needed: Engineer1 runs CREATE CATALOG without a MANAGED LOCATION clause, then adds the managed location afterwards. Breaks a stated condition: the metastore has no default storage location, so managed storage must be specified when the catalog is created.
  • Not needed: Admin1 grants Engineer1 USE CATALOG and CREATE SCHEMA on prod_catalog. These are the privileges for creating schemas inside a catalog, a separate procedure; they are not needed to create the catalog or set its managed storage.
  • Not needed: Engineer1 runs CREATE SCHEMA prod_catalog.default. Not needed: a new catalog already includes an automatically generated default schema.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free