w.catalogs: Catalogs

class databricks.sdk.service.catalog.CatalogsAPI

A catalog is the first layer of Unity Catalog’s three-level namespace. It’s used to organize your data assets. Users can see all catalogs on which they have been assigned the USE_CATALOG data permission.

In Unity Catalog, admins and data stewards manage users and their access to data centrally across all of the workspaces in a Databricks account. Users in different workspaces can share access to the same data, depending on privileges granted centrally in Unity Catalog.

create(name: str [, comment: Optional[str], connection_name: Optional[str], options: Optional[Dict[str, str]], properties: Optional[Dict[str, str]], provider_name: Optional[str], share_name: Optional[str], storage_root: Optional[str]]) CatalogInfo

Usage:

import time

from databricks.sdk import WorkspaceClient

w = WorkspaceClient()

created = w.catalogs.create(name=f'sdk-{time.time_ns()}')

# cleanup
w.catalogs.delete(name=created.name, force=True)

Create a catalog.

Creates a new catalog instance in the parent metastore if the caller is a metastore admin or has the CREATE_CATALOG privilege.

Parameters:
  • name – str Name of catalog.

  • comment – str (optional) User-provided free-form text description.

  • connection_name – str (optional) The name of the connection to an external data source.

  • options – Dict[str,str] (optional) A map of key-value properties attached to the securable.

  • properties – Dict[str,str] (optional) A map of key-value properties attached to the securable.

  • provider_name

    str (optional) The name of delta sharing provider.

    A Delta Sharing catalog is a catalog that is based on a Delta share on a remote sharing server.

  • share_name – str (optional) The name of the share under the share provider.

  • storage_root – str (optional) Storage root URL for managed tables within catalog.

Returns:

CatalogInfo

delete(name: str [, force: Optional[bool]])

Delete a catalog.

Deletes the catalog that matches the supplied name. The caller must be a metastore admin or the owner of the catalog.

Parameters:
  • name – str The name of the catalog.

  • force – bool (optional) Force deletion even if the catalog is not empty.

get(name: str [, include_browse: Optional[bool]]) CatalogInfo

Usage:

import time

from databricks.sdk import WorkspaceClient

w = WorkspaceClient()

created = w.catalogs.create(name=f'sdk-{time.time_ns()}')

_ = w.catalogs.get(name=created.name)

# cleanup
w.catalogs.delete(name=created.name, force=True)

Get a catalog.

Gets the specified catalog in a metastore. The caller must be a metastore admin, the owner of the catalog, or a user that has the USE_CATALOG privilege set for their account.

Parameters:
  • name – str The name of the catalog.

  • include_browse – bool (optional) Whether to include catalogs in the response for which the principal can only access selective metadata for

Returns:

CatalogInfo

list([, include_browse: Optional[bool]]) Iterator[CatalogInfo]

Usage:

from databricks.sdk import WorkspaceClient
from databricks.sdk.service import catalog

w = WorkspaceClient()

all = w.catalogs.list(catalog.ListCatalogsRequest())

List catalogs.

Gets an array of catalogs in the metastore. If the caller is the metastore admin, all catalogs will be retrieved. Otherwise, only catalogs owned by the caller (or for which the caller has the USE_CATALOG privilege) will be retrieved. There is no guarantee of a specific ordering of the elements in the array.

Parameters:

include_browse – bool (optional) Whether to include catalogs in the response for which the principal can only access selective metadata for

Returns:

Iterator over CatalogInfo

update(name: str [, comment: Optional[str], enable_predictive_optimization: Optional[EnablePredictiveOptimization], isolation_mode: Optional[IsolationMode], new_name: Optional[str], owner: Optional[str], properties: Optional[Dict[str, str]]]) CatalogInfo

Usage:

import time

from databricks.sdk import WorkspaceClient

w = WorkspaceClient()

created = w.catalogs.create(name=f'sdk-{time.time_ns()}')

_ = w.catalogs.update(name=created.name, comment="updated")

# cleanup
w.catalogs.delete(name=created.name, force=True)

Update a catalog.

Updates the catalog that matches the supplied name. The caller must be either the owner of the catalog, or a metastore admin (when changing the owner field of the catalog).

Parameters:
  • name – str The name of the catalog.

  • comment – str (optional) User-provided free-form text description.

  • enable_predictive_optimizationEnablePredictiveOptimization (optional) Whether predictive optimization should be enabled for this object and objects under it.

  • isolation_modeIsolationMode (optional) Whether the current securable is accessible from all workspaces or a specific set of workspaces.

  • new_name – str (optional) New name for the catalog.

  • owner – str (optional) Username of current owner of catalog.

  • properties – Dict[str,str] (optional) A map of key-value properties attached to the securable.

Returns:

CatalogInfo