32#include <unordered_map>
33#include <unordered_set>
46constexpr static int32_t kMaxConnections = 10;
52 std::string name =
"sql_catalog";
59 int32_t max_connections = kMaxConnections;
61 std::unordered_map<std::string, std::string>
props;
67 public std::enable_shared_from_this<SqlCatalog> {
87 std::shared_ptr<FileIO> file_io,
88 std::shared_ptr<CatalogStore> store);
90 std::string_view
name()
const override;
94 const std::unordered_map<std::string, std::string>& properties)
override;
106 const Namespace& ns,
const std::unordered_map<std::string, std::string>& updates,
107 const std::unordered_set<std::string>& removals)
override;
112 const TableIdentifier& identifier,
const std::shared_ptr<Schema>& schema,
113 const std::shared_ptr<PartitionSpec>& spec,
const std::shared_ptr<SortOrder>& order,
114 const std::string& location,
115 const std::unordered_map<std::string, std::string>& properties)
override;
119 const std::vector<std::unique_ptr<TableRequirement>>& requirements,
120 const std::vector<std::unique_ptr<TableUpdate>>& updates)
override;
123 const TableIdentifier& identifier,
const std::shared_ptr<Schema>& schema,
124 const std::shared_ptr<PartitionSpec>& spec,
const std::shared_ptr<SortOrder>& order,
125 const std::string& location,
126 const std::unordered_map<std::string, std::string>& properties)
override;
142 const std::string& metadata_file_location)
override;
175 std::shared_ptr<CatalogStore> store,
176 std::shared_ptr<MetricsReporter> reporter);
183 const std::string& metadata_location);
186 std::shared_ptr<FileIO> file_io_;
187 std::shared_ptr<CatalogStore> store_;
188 std::shared_ptr<MetricsReporter> reporter_;
Define the catalog API for table and namespace operations.
A Catalog API for table create, drop, and load operations.
Definition catalog.h:42
SQL-backed Iceberg catalog.
Definition sql_catalog.h:67
Status CreateNamespace(const Namespace &ns, const std::unordered_map< std::string, std::string > &properties) override
Create a namespace with associated properties.
static Result< std::shared_ptr< SqlCatalog > > Make(const SqlCatalogConfig &config, std::shared_ptr< FileIO > file_io, std::shared_ptr< CatalogStore > store)
Create a catalog backed by a user-supplied CatalogStore.
std::string_view name() const override
Return the name for this catalog.
Result< bool > NamespaceExists(const Namespace &ns) const override
Check whether the namespace exists.
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) override
Update a table.
Result< std::vector< Namespace > > ListNamespaces(const Namespace &ns) const override
List child namespaces from the given namespace.
Result< std::unordered_map< std::string, std::string > > GetNamespaceProperties(const Namespace &ns) const override
Get metadata properties for a namespace.
Result< std::shared_ptr< Table > > LoadTable(const TableIdentifier &identifier) override
Load a table.
static Result< std::shared_ptr< SqlCatalog > > MakeMySqlCatalog(const SqlCatalogConfig &config, std::shared_ptr< FileIO > file_io)
Create a catalog backed by the built-in MySQL client.
Status DropNamespace(const Namespace &ns) override
Drop a namespace.
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) override
Start a transaction to create a table.
Result< std::vector< TableIdentifier > > ListTables(const Namespace &ns) const override
Return all the identifiers under this namespace.
Status RenameTable(const TableIdentifier &from, const TableIdentifier &to) override
Rename a table.
Status DropTable(const TableIdentifier &identifier, bool purge) override
Drop a table.
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) override
Create a table.
Status UpdateNamespaceProperties(const Namespace &ns, const std::unordered_map< std::string, std::string > &updates, const std::unordered_set< std::string > &removals) override
Update a namespace's properties by applying additions and removals.
static Result< std::shared_ptr< SqlCatalog > > MakePostgreSqlCatalog(const SqlCatalogConfig &config, std::shared_ptr< FileIO > file_io)
Create a catalog backed by the built-in PostgreSQL (libpq) client.
Result< bool > TableExists(const TableIdentifier &identifier) const override
Check whether table exists.
Result< std::shared_ptr< Table > > RegisterTable(const TableIdentifier &identifier, const std::string &metadata_file_location) override
Register a table with the catalog if it does not exist.
static Result< std::shared_ptr< SqlCatalog > > MakeSqliteCatalog(const SqlCatalogConfig &config, std::shared_ptr< FileIO > file_io)
Create a catalog backed by the built-in SQLite client.
Define symbol visibility macros for the SQL catalog library.
SQL catalog APIs.
Definition catalog_store.h:41
std::expected< T, E > Result
Result alias.
Definition result.h:88
Define Result, Status, and error helpers.
A namespace in a catalog.
Definition table_identifier.h:35
Identifies a table in iceberg catalog.
Definition table_identifier.h:46
Configuration for the SQL catalog.
Definition sql_catalog.h:49
std::string warehouse_location
Base location used to derive table locations when none is supplied.
Definition sql_catalog.h:56
std::string uri
Database connection string interpreted by the chosen CatalogStore.
Definition sql_catalog.h:54
std::unordered_map< std::string, std::string > props
Additional connector-specific properties.
Definition sql_catalog.h:61