iceberg-cpp
Loading...
Searching...
No Matches
catalog.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
22#include <memory>
23#include <string>
24#include <string_view>
25#include <unordered_map>
26#include <unordered_set>
27#include <vector>
28
29#include "iceberg/result.h"
31#include "iceberg/type_fwd.h"
32
33namespace iceberg {
34
39class ICEBERG_EXPORT Catalog {
40 public:
41 virtual ~Catalog() = default;
42
44 virtual std::string_view name() const = 0;
45
53 virtual Status CreateNamespace(
54 const Namespace& ns,
55 const std::unordered_map<std::string, std::string>& properties) = 0;
56
62 virtual Result<std::vector<Namespace>> ListNamespaces(const Namespace& ns) const = 0;
63
69 virtual Result<std::unordered_map<std::string, std::string>> GetNamespaceProperties(
70 const Namespace& ns) const = 0;
71
78 virtual Status DropNamespace(const Namespace& ns) = 0;
79
84 virtual Result<bool> NamespaceExists(const Namespace& ns) const = 0;
85
95 const Namespace& ns, const std::unordered_map<std::string, std::string>& updates,
96 const std::unordered_set<std::string>& removals) = 0;
97
103 virtual Result<std::vector<TableIdentifier>> ListTables(const Namespace& ns) const = 0;
104
114 virtual Result<std::shared_ptr<Table>> CreateTable(
115 const TableIdentifier& identifier, const std::shared_ptr<Schema>& schema,
116 const std::shared_ptr<PartitionSpec>& spec, const std::shared_ptr<SortOrder>& order,
117 const std::string& location,
118 const std::unordered_map<std::string, std::string>& properties) = 0;
119
126 virtual Result<std::shared_ptr<Table>> UpdateTable(
127 const TableIdentifier& identifier,
128 const std::vector<std::unique_ptr<TableRequirement>>& requirements,
129 const std::vector<std::unique_ptr<TableUpdate>>& updates) = 0;
130
141 virtual Result<std::shared_ptr<Transaction>> StageCreateTable(
142 const TableIdentifier& identifier, const std::shared_ptr<Schema>& schema,
143 const std::shared_ptr<PartitionSpec>& spec, const std::shared_ptr<SortOrder>& order,
144 const std::string& location,
145 const std::unordered_map<std::string, std::string>& properties) = 0;
146
154 virtual Result<bool> TableExists(const TableIdentifier& identifier) const = 0;
155
166 virtual Status DropTable(const TableIdentifier& identifier, bool purge) = 0;
167
175 virtual Status RenameTable(const TableIdentifier& from, const TableIdentifier& to) = 0;
176
182 virtual Result<std::shared_ptr<Table>> LoadTable(const TableIdentifier& identifier) = 0;
183
189 virtual Result<std::shared_ptr<Table>> RegisterTable(
190 const TableIdentifier& identifier, const std::string& metadata_file_location) = 0;
191};
192
193} // namespace iceberg
A Catalog API for table create, drop, and load operations.
Definition catalog.h:39
virtual Result< bool > NamespaceExists(const Namespace &ns) const =0
Check whether the namespace exists.
virtual Status DropTable(const TableIdentifier &identifier, bool purge)=0
Drop a table; optionally delete data and metadata files.
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< 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 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::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 std::string_view name() const =0
Return the name for this catalog.
virtual Status DropNamespace(const Namespace &ns)=0
Drop a namespace.
virtual Result< bool > TableExists(const TableIdentifier &identifier) const =0
Check whether table exists.
virtual Result< std::shared_ptr< Table > > LoadTable(const TableIdentifier &identifier)=0
Load a table.
virtual Result< std::vector< TableIdentifier > > ListTables(const Namespace &ns) const =0
Return all the identifiers under this namespace.
virtual Result< std::vector< Namespace > > ListNamespaces(const Namespace &ns) const =0
List child namespaces from the given namespace.
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.
virtual Status RenameTable(const TableIdentifier &from, const TableIdentifier &to)=0
Rename a table.
virtual Result< std::unordered_map< std::string, std::string > > GetNamespaceProperties(const Namespace &ns) const =0
Get metadata properties for a namespace.
virtual Status CreateNamespace(const Namespace &ns, const std::unordered_map< std::string, std::string > &properties)=0
Create a namespace with associated properties.
A namespace in a catalog.
Definition table_identifier.h:35
Identifies a table in iceberg catalog.
Definition table_identifier.h:46