iceberg-cpp
Loading...
Searching...
No Matches
Public Member Functions | List of all members
iceberg::Catalog Class Referenceabstract

A Catalog API for table create, drop, and load operations. More...

#include <catalog.h>

Inheritance diagram for iceberg::Catalog:
iceberg::InMemoryCatalog iceberg::MockCatalog iceberg::rest::RestCatalog

Public Member Functions

virtual std::string_view name () const =0
 Return the name for this catalog.
 
virtual Status CreateNamespace (const Namespace &ns, const std::unordered_map< std::string, std::string > &properties)=0
 Create a namespace with associated properties.
 
virtual Result< std::vector< Namespace > > ListNamespaces (const Namespace &ns) const =0
 List child namespaces from the given namespace.
 
virtual Result< std::unordered_map< std::string, std::string > > GetNamespaceProperties (const Namespace &ns) const =0
 Get metadata properties for a namespace.
 
virtual Status DropNamespace (const Namespace &ns)=0
 Drop a namespace.
 
virtual Result< bool > NamespaceExists (const Namespace &ns) const =0
 Check whether the namespace exists.
 
virtual Status UpdateNamespaceProperties (const Namespace &ns, const std::unordered_map< std::string, std::string > &updates, const std::unordered_set< std::string > &removals)=0
 Update a namespace's properties by applying additions and removals.
 
virtual Result< std::vector< TableIdentifier > > ListTables (const Namespace &ns) const =0
 Return all the identifiers under this namespace.
 
virtual Result< std::shared_ptr< Table > > CreateTable (const TableIdentifier &identifier, const std::shared_ptr< Schema > &schema, const std::shared_ptr< PartitionSpec > &spec, const std::shared_ptr< SortOrder > &order, const std::string &location, const std::unordered_map< std::string, std::string > &properties)=0
 Create a table.
 
virtual Result< std::shared_ptr< Table > > UpdateTable (const TableIdentifier &identifier, const std::vector< std::unique_ptr< TableRequirement > > &requirements, const std::vector< std::unique_ptr< TableUpdate > > &updates)=0
 Update a table.
 
virtual Result< std::shared_ptr< Transaction > > StageCreateTable (const TableIdentifier &identifier, const std::shared_ptr< Schema > &schema, const std::shared_ptr< PartitionSpec > &spec, const std::shared_ptr< SortOrder > &order, const std::string &location, const std::unordered_map< std::string, std::string > &properties)=0
 Start a transaction to create a table.
 
virtual Result< bool > TableExists (const TableIdentifier &identifier) const =0
 Check whether table exists.
 
virtual Status DropTable (const TableIdentifier &identifier, bool purge)=0
 Drop a table; optionally delete data and metadata files.
 
virtual Status RenameTable (const TableIdentifier &from, const TableIdentifier &to)=0
 Rename a table.
 
virtual Result< std::shared_ptr< Table > > LoadTable (const TableIdentifier &identifier)=0
 Load a table.
 
virtual Result< std::shared_ptr< Table > > RegisterTable (const TableIdentifier &identifier, const std::string &metadata_file_location)=0
 Register a table with the catalog if it does not exist.
 

Detailed Description

A Catalog API for table create, drop, and load operations.

Note that these functions are named after the corresponding operationId specified by the Iceberg Rest Catalog API.

Member Function Documentation

◆ CreateNamespace()

virtual Status iceberg::Catalog::CreateNamespace ( const Namespace ns,
const std::unordered_map< std::string, std::string > &  properties 
)
pure virtual

Create a namespace with associated properties.

Parameters
nsthe namespace to create
propertiesa key-value map of metadata for the namespace
Returns
Status indicating success if created successfully; ErrorKind::kAlreadyExists if the namespace already exists; ErrorKind::kNotSupported if the operation is not supported

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ CreateTable()

virtual Result< std::shared_ptr< Table > > iceberg::Catalog::CreateTable ( const TableIdentifier identifier,
const std::shared_ptr< Schema > &  schema,
const std::shared_ptr< PartitionSpec > &  spec,
const std::shared_ptr< SortOrder > &  order,
const std::string &  location,
const std::unordered_map< std::string, std::string > &  properties 
)
pure virtual

Create a table.

Parameters
identifiera table identifier
schemaa schema
speca partition spec
ordera sort order
locationa location for the table; leave empty if unspecified
propertiesa string map of table properties
Returns
a Table instance or ErrorKind::kAlreadyExists if the table already exists

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ DropNamespace()

virtual Status iceberg::Catalog::DropNamespace ( const Namespace ns)
pure virtual

Drop a namespace.

Parameters
nsthe namespace to drop
Returns
Status indicating success if dropped successfully; ErrorKind::kNoSuchNamespace if the namespace does not exist; ErrorKind::kNotAllowed if the namespace is not empty

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ DropTable()

virtual Status iceberg::Catalog::DropTable ( const TableIdentifier identifier,
bool  purge 
)
pure virtual

Drop a table; optionally delete data and metadata files.

If purge is set to true the implementation should delete all data and metadata files.

Parameters
identifiera table identifier
purgeif true, delete all data and metadata files in the table
Returns
Status indicating the outcome of the operation.
  • On success, the table was dropped (or did not exist).
  • On failure, contains error information.

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ GetNamespaceProperties()

virtual Result< std::unordered_map< std::string, std::string > > iceberg::Catalog::GetNamespaceProperties ( const Namespace ns) const
pure virtual

Get metadata properties for a namespace.

Parameters
nsthe namespace to look up
Returns
a key-value map of metadata properties; ErrorKind::kNoSuchNamespace if the namespace does not exist

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ ListNamespaces()

virtual Result< std::vector< Namespace > > iceberg::Catalog::ListNamespaces ( const Namespace ns) const
pure virtual

List child namespaces from the given namespace.

Parameters
nsthe parent namespace
Returns
a list of child namespaces; ErrorKind::kNoSuchNamespace if the given namespace does not exist

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ ListTables()

virtual Result< std::vector< TableIdentifier > > iceberg::Catalog::ListTables ( const Namespace ns) const
pure virtual

Return all the identifiers under this namespace.

Parameters
nsa namespace
Returns
a list of identifiers for tables or ErrorKind::kNoSuchNamespace if the namespace does not exist

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ LoadTable()

virtual Result< std::shared_ptr< Table > > iceberg::Catalog::LoadTable ( const TableIdentifier identifier)
pure virtual

Load a table.

Parameters
identifiera table identifier
Returns
instance of Table implementation referred to by identifier or ErrorKind::kNoSuchTable if the table does not exist

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ name()

virtual std::string_view iceberg::Catalog::name ( ) const
pure virtual

Return the name for this catalog.

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ NamespaceExists()

virtual Result< bool > iceberg::Catalog::NamespaceExists ( const Namespace ns) const
pure virtual

Check whether the namespace exists.

Parameters
nsthe namespace to check
Returns
true if the namespace exists, false otherwise

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ RegisterTable()

virtual Result< std::shared_ptr< Table > > iceberg::Catalog::RegisterTable ( const TableIdentifier identifier,
const std::string &  metadata_file_location 
)
pure virtual

Register a table with the catalog if it does not exist.

Parameters
identifiera table identifier
metadata_file_locationthe location of a metadata file
Returns
a Table instance or ErrorKind::kAlreadyExists if the table already exists

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ RenameTable()

virtual Status iceberg::Catalog::RenameTable ( const TableIdentifier from,
const TableIdentifier to 
)
pure virtual

Rename a table.

Parameters
fromthe current table identifier
tothe new table identifier
Returns
Status indicating the outcome of the operation.
  • On success, the table was renamed.
  • On failure, contains error information.

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ StageCreateTable()

virtual Result< std::shared_ptr< Transaction > > iceberg::Catalog::StageCreateTable ( const TableIdentifier identifier,
const std::shared_ptr< Schema > &  schema,
const std::shared_ptr< PartitionSpec > &  spec,
const std::shared_ptr< SortOrder > &  order,
const std::string &  location,
const std::unordered_map< std::string, std::string > &  properties 
)
pure virtual

Start a transaction to create a table.

Parameters
identifiera table identifier
schemaa schema
speca partition spec
ordera sort order
locationa location for the table; leave empty if unspecified
propertiesa string map of table properties
Returns
a Transaction to create the table or ErrorKind::kAlreadyExists if the table already exists

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ TableExists()

virtual Result< bool > iceberg::Catalog::TableExists ( const TableIdentifier identifier) const
pure virtual

Check whether table exists.

Parameters
identifiera table identifier
Returns
Result<bool> indicating table exists or not.
  • On success, the table existence was successfully checked (actual existence may be inferred elsewhere).
  • On failure, contains error information.

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ UpdateNamespaceProperties()

virtual Status iceberg::Catalog::UpdateNamespaceProperties ( const Namespace ns,
const std::unordered_map< std::string, std::string > &  updates,
const std::unordered_set< std::string > &  removals 
)
pure virtual

Update a namespace's properties by applying additions and removals.

Parameters
nsthe namespace to update
updatesa set of properties to add or overwrite
removalsa set of property keys to remove
Returns
Status indicating success if the update is successful; ErrorKind::kNoSuchNamespace if the namespace does not exist; ErrorKind::kUnsupported if the operation is not supported

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.

◆ UpdateTable()

virtual Result< std::shared_ptr< Table > > iceberg::Catalog::UpdateTable ( const TableIdentifier identifier,
const std::vector< std::unique_ptr< TableRequirement > > &  requirements,
const std::vector< std::unique_ptr< TableUpdate > > &  updates 
)
pure virtual

Update a table.

Parameters
identifiera table identifier
requirementsa list of table requirements
updatesa list of table updates
Returns
a Table instance or ErrorKind::kAlreadyExists if the table already exists

Implemented in iceberg::InMemoryCatalog, and iceberg::rest::RestCatalog.


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