Databricks C++ SDK 0.2.4
Interact with Databricks via an SDK
Loading...
Searching...
No Matches
databricks::UnityCatalog Class Reference

Client for interacting with the Databricks Unity Catalog API. More...

#include <unity_catalog.h>

Public Member Functions

 UnityCatalog (const AuthConfig &auth, const std::string &api_version="2.1")
 Construct a Unity Catalog API client.
 
 UnityCatalog (std::shared_ptr< internal::IHttpClient > http_client)
 Construct a Unity Catalog API client with dependency injection (for testing)
 
 ~UnityCatalog ()
 Destructor.
 
 UnityCatalog (const UnityCatalog &)=delete
 
UnityCatalogoperator= (const UnityCatalog &)=delete
 
std::vector< CatalogInfolist_catalogs ()
 List all catalogs in the metastore.
 
CatalogInfo get_catalog (const std::string &catalog_name)
 Get detailed information about a specific catalog.
 
CatalogInfo create_catalog (const CreateCatalogRequest &request)
 Create a new catalog.
 
CatalogInfo update_catalog (const UpdateCatalogRequest &request)
 Update an existing catalog.
 
bool delete_catalog (const std::string &catalog_name, bool force=false)
 Delete a catalog.
 
std::vector< SchemaInfolist_schemas (const std::string &catalog_name)
 List all schemas in a catalog.
 
SchemaInfo get_schema (const std::string &full_name)
 Get detailed information about a specific schema.
 
SchemaInfo create_schema (const CreateSchemaRequest &request)
 Create a new schema.
 
SchemaInfo update_schema (const UpdateSchemaRequest &request)
 Update an existing schema.
 
bool delete_schema (const std::string &full_name)
 Delete a schema.
 
std::vector< TableInfolist_tables (const std::string &catalog_name, const std::string &schema_name)
 List all tables in a schema.
 
TableInfo get_table (const std::string &full_name)
 Get detailed information about a specific table.
 
bool delete_table (const std::string &full_name)
 Delete a table.
 

Detailed Description

Client for interacting with the Databricks Unity Catalog API.

Unity Catalog provides a unified governance solution for data and AI assets. This implementation uses Unity Catalog REST API 2.1.

Example usage:

// List all catalogs
auto catalogs = uc.list_catalogs();
// Get specific catalog details
auto catalog = uc.get_catalog("main");
// Create a new catalog
req.name = "my_catalog";
req.comment = "My data catalog";
uc.create_catalog(req);
// List schemas in a catalog
auto schemas = uc.list_schemas("main");
// List tables in a schema
auto tables = uc.list_tables("main", "default");
Client for interacting with the Databricks Unity Catalog API.
Core authentication configuration shared across all Databricks features.
Definition config.h:16
static AuthConfig from_environment(const std::string &profile="DEFAULT")
Load authentication configuration from all available sources.
Configuration for creating a catalog.
std::string comment
User-provided description.
std::string name
Name of the catalog (required)

Definition at line 46 of file unity_catalog.h.

Constructor & Destructor Documentation

◆ UnityCatalog() [1/3]

databricks::UnityCatalog::UnityCatalog ( const AuthConfig auth,
const std::string &  api_version = "2.1" 
)
explicit

Construct a Unity Catalog API client.

Parameters
authAuthentication configuration with host and token
api_versionUnity Catalog API version to use (default: "2.1")

◆ UnityCatalog() [2/3]

databricks::UnityCatalog::UnityCatalog ( std::shared_ptr< internal::IHttpClient >  http_client)
explicit

Construct a Unity Catalog API client with dependency injection (for testing)

Parameters
http_clientInjected HTTP client (use MockHttpClient for unit tests)
Note
This constructor is primarily for testing with mock HTTP clients

◆ ~UnityCatalog()

databricks::UnityCatalog::~UnityCatalog ( )

Destructor.

◆ UnityCatalog() [3/3]

databricks::UnityCatalog::UnityCatalog ( const UnityCatalog )
delete

Member Function Documentation

◆ create_catalog()

CatalogInfo databricks::UnityCatalog::create_catalog ( const CreateCatalogRequest request)

Create a new catalog.

Parameters
requestConfiguration for the new catalog
Returns
CatalogInfo object representing the created catalog
Exceptions
std::runtime_errorif the API request fails

◆ create_schema()

SchemaInfo databricks::UnityCatalog::create_schema ( const CreateSchemaRequest request)

Create a new schema.

Parameters
requestConfiguration for the new schema
Returns
SchemaInfo object representing the created schema
Exceptions
std::runtime_errorif the API request fails

◆ delete_catalog()

bool databricks::UnityCatalog::delete_catalog ( const std::string &  catalog_name,
bool  force = false 
)

Delete a catalog.

Parameters
catalog_nameThe name of the catalog to delete
forceIf true, deletes the catalog even if it's not empty
Returns
true if the operation was successful
Exceptions
std::runtime_errorif the API request fails
Note
By default, you cannot delete a catalog that contains schemas. Set force=true to delete a catalog and all its contents.

◆ delete_schema()

bool databricks::UnityCatalog::delete_schema ( const std::string &  full_name)

Delete a schema.

Parameters
full_nameThe full name of the schema to delete (catalog.schema)
Returns
true if the operation was successful
Exceptions
std::runtime_errorif the API request fails
Note
The schema must be empty (no tables) before deletion

◆ delete_table()

bool databricks::UnityCatalog::delete_table ( const std::string &  full_name)

Delete a table.

Parameters
full_nameThe full name of the table to delete (catalog.schema.table)
Returns
true if the operation was successful
Exceptions
std::runtime_errorif the API request fails
Note
For managed tables, this also deletes the underlying data. For external tables, only the metadata is deleted.

◆ get_catalog()

CatalogInfo databricks::UnityCatalog::get_catalog ( const std::string &  catalog_name)

Get detailed information about a specific catalog.

Parameters
catalog_nameThe name of the catalog
Returns
CatalogInfo object with full details
Exceptions
std::runtime_errorif the catalog is not found or the API request fails

◆ get_schema()

SchemaInfo databricks::UnityCatalog::get_schema ( const std::string &  full_name)

Get detailed information about a specific schema.

Parameters
full_nameThe full name of the schema (catalog.schema)
Returns
SchemaInfo object with full details
Exceptions
std::runtime_errorif the schema is not found or the API request fails

◆ get_table()

TableInfo databricks::UnityCatalog::get_table ( const std::string &  full_name)

Get detailed information about a specific table.

Parameters
full_nameThe full name of the table (catalog.schema.table)
Returns
TableInfo object with full details
Exceptions
std::runtime_errorif the table is not found or the API request fails

◆ list_catalogs()

std::vector< CatalogInfo > databricks::UnityCatalog::list_catalogs ( )

List all catalogs in the metastore.

Returns
Vector of CatalogInfo objects
Exceptions
std::runtime_errorif the API request fails

◆ list_schemas()

std::vector< SchemaInfo > databricks::UnityCatalog::list_schemas ( const std::string &  catalog_name)

List all schemas in a catalog.

Parameters
catalog_nameThe name of the catalog
Returns
Vector of SchemaInfo objects
Exceptions
std::runtime_errorif the API request fails

◆ list_tables()

std::vector< TableInfo > databricks::UnityCatalog::list_tables ( const std::string &  catalog_name,
const std::string &  schema_name 
)

List all tables in a schema.

Parameters
catalog_nameThe name of the catalog
schema_nameThe name of the schema
Returns
Vector of TableInfo objects
Exceptions
std::runtime_errorif the API request fails

◆ operator=()

UnityCatalog & databricks::UnityCatalog::operator= ( const UnityCatalog )
delete

◆ update_catalog()

CatalogInfo databricks::UnityCatalog::update_catalog ( const UpdateCatalogRequest request)

Update an existing catalog.

Parameters
requestConfiguration for updating the catalog
Returns
CatalogInfo object representing the updated catalog
Exceptions
std::runtime_errorif the API request fails

◆ update_schema()

SchemaInfo databricks::UnityCatalog::update_schema ( const UpdateSchemaRequest request)

Update an existing schema.

Parameters
requestConfiguration for updating the schema
Returns
SchemaInfo object representing the updated schema
Exceptions
std::runtime_errorif the API request fails

The documentation for this class was generated from the following file: