Skip to content

Commit fc2ca57

Browse files
authored
Merge branch 'main' into feature/my-feature
2 parents 89388f2 + 5aec271 commit fc2ca57

File tree

9 files changed

+875
-18
lines changed

9 files changed

+875
-18
lines changed

src/iceberg/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ set(ICEBERG_INCLUDES "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>"
1919
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>")
2020
set(ICEBERG_SOURCES
2121
arrow_c_data_internal.cc
22+
catalog/in_memory_catalog.cc
2223
demo.cc
2324
expression/expression.cc
2425
file_reader.cc
@@ -76,6 +77,7 @@ add_iceberg_lib(iceberg
7677

7778
iceberg_install_all_headers(iceberg)
7879

80+
add_subdirectory(catalog)
7981
add_subdirectory(expression)
8082
add_subdirectory(util)
8183

src/iceberg/catalog.h

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <string>
2424
#include <string_view>
2525
#include <unordered_map>
26+
#include <unordered_set>
2627
#include <vector>
2728

2829
#include "iceberg/result.h"
@@ -42,6 +43,58 @@ class ICEBERG_EXPORT Catalog {
4243
/// \brief Return the name for this catalog
4344
virtual std::string_view name() const = 0;
4445

46+
/// \brief Create a namespace with associated properties.
47+
///
48+
/// \param ns the namespace to create
49+
/// \param properties a key-value map of metadata for the namespace
50+
/// \return Status::OK if created successfully;
51+
/// ErrorKind::kAlreadyExists if the namespace already exists;
52+
/// ErrorKind::kNotSupported if the operation is not supported
53+
virtual Status CreateNamespace(
54+
const Namespace& ns,
55+
const std::unordered_map<std::string, std::string>& properties) = 0;
56+
57+
/// \brief List child namespaces from the given namespace.
58+
///
59+
/// \param ns the parent namespace
60+
/// \return a list of child namespaces;
61+
/// ErrorKind::kNoSuchNamespace if the given namespace does not exist
62+
virtual Result<std::vector<Namespace>> ListNamespaces(const Namespace& ns) const = 0;
63+
64+
/// \brief Get metadata properties for a namespace.
65+
///
66+
/// \param ns the namespace to look up
67+
/// \return a key-value map of metadata properties;
68+
/// ErrorKind::kNoSuchNamespace if the namespace does not exist
69+
virtual Result<std::unordered_map<std::string, std::string>> GetNamespaceProperties(
70+
const Namespace& ns) const = 0;
71+
72+
/// \brief Drop a namespace.
73+
///
74+
/// \param ns the namespace to drop
75+
/// \return Status::OK if dropped successfully;
76+
/// ErrorKind::kNoSuchNamespace if the namespace does not exist;
77+
/// ErrorKind::kNotAllowed if the namespace is not empty
78+
virtual Status DropNamespace(const Namespace& ns) = 0;
79+
80+
/// \brief Check whether the namespace exists.
81+
///
82+
/// \param ns the namespace to check
83+
/// \return true if the namespace exists, false otherwise
84+
virtual Result<bool> NamespaceExists(const Namespace& ns) const = 0;
85+
86+
/// \brief Update a namespace's properties by applying additions and removals.
87+
///
88+
/// \param ns the namespace to update
89+
/// \param updates a set of properties to add or overwrite
90+
/// \param removals a set of property keys to remove
91+
/// \return Status::OK if the update is successful;
92+
/// ErrorKind::kNoSuchNamespace if the namespace does not exist;
93+
/// ErrorKind::kUnsupported if the operation is not supported
94+
virtual Status UpdateNamespaceProperties(
95+
const Namespace& ns, const std::unordered_map<std::string, std::string>& updates,
96+
const std::unordered_set<std::string>& removals) = 0;
97+
4598
/// \brief Return all the identifiers under this namespace
4699
///
47100
/// \param ns a namespace
@@ -80,8 +133,8 @@ class ICEBERG_EXPORT Catalog {
80133
/// \param spec a partition spec
81134
/// \param location a location for the table; leave empty if unspecified
82135
/// \param properties a string map of table properties
83-
/// \return a Transaction to create the table or ErrorKind::kAlreadyExists if the table
84-
/// already exists
136+
/// \return a Transaction to create the table or ErrorKind::kAlreadyExists if the
137+
/// table already exists
85138
virtual Result<std::shared_ptr<Transaction>> StageCreateTable(
86139
const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec,
87140
const std::string& location,
@@ -90,8 +143,11 @@ class ICEBERG_EXPORT Catalog {
90143
/// \brief Check whether table exists
91144
///
92145
/// \param identifier a table identifier
93-
/// \return true if the table exists, false otherwise
94-
virtual bool TableExists(const TableIdentifier& identifier) const = 0;
146+
/// \return Result<bool> indicating table exists or not.
147+
/// - On success, the table existence was successfully checked (actual
148+
/// existence may be inferred elsewhere).
149+
/// - On failure, contains error information.
150+
virtual Result<bool> TableExists(const TableIdentifier& identifier) const = 0;
95151

96152
/// \brief Drop a table; optionally delete data and metadata files
97153
///
@@ -100,8 +156,10 @@ class ICEBERG_EXPORT Catalog {
100156
///
101157
/// \param identifier a table identifier
102158
/// \param purge if true, delete all data and metadata files in the table
103-
/// \return true if the table was dropped, false if the table did not exist
104-
virtual bool DropTable(const TableIdentifier& identifier, bool purge) = 0;
159+
/// \return Status indicating the outcome of the operation.
160+
/// - On success, the table was dropped (or did not exist).
161+
/// - On failure, contains error information.
162+
virtual Status DropTable(const TableIdentifier& identifier, bool purge) = 0;
105163

106164
/// \brief Load a table
107165
///
@@ -119,18 +177,6 @@ class ICEBERG_EXPORT Catalog {
119177
virtual Result<std::shared_ptr<Table>> RegisterTable(
120178
const TableIdentifier& identifier, const std::string& metadata_file_location) = 0;
121179

122-
/// \brief Initialize a catalog given a custom name and a map of catalog properties
123-
///
124-
/// A custom Catalog implementation must have a default constructor. A compute engine
125-
/// will first initialize the catalog without any arguments, and then call this method
126-
/// to complete catalog initialization with properties passed into the engine.
127-
///
128-
/// \param name a custom name for the catalog
129-
/// \param properties catalog properties
130-
virtual void Initialize(
131-
const std::string& name,
132-
const std::unordered_map<std::string, std::string>& properties) = 0;
133-
134180
/// \brief Instantiate a builder to either create a table or start a create/replace
135181
/// transaction
136182
///

src/iceberg/catalog/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
iceberg_install_all_headers(iceberg/catalog)

0 commit comments

Comments
 (0)