Skip to content

Commit 6697df9

Browse files
author
shuxu.li
committed
feat: add table create/replace/update interface to catalog
1 parent 564ca06 commit 6697df9

File tree

7 files changed

+3
-47
lines changed

7 files changed

+3
-47
lines changed

src/iceberg/catalog.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,6 @@ class ICEBERG_EXPORT Catalog {
140140
const std::string& location,
141141
const std::unordered_map<std::string, std::string>& properties) = 0;
142142

143-
/// \brief Start a transaction to replace a table
144-
///
145-
/// \param identifier a table identifier
146-
/// \param schema a schema
147-
/// \param spec a partition spec
148-
/// \param location a location for the table; leave empty if unspecified
149-
/// \param properties a string map of table properties
150-
/// \param orCreate whether to create the table if not exists
151-
/// \return a Transaction to replace the table or ErrorKind::kNotFound if the table
152-
/// doesn't exist and orCreate is false
153-
virtual Result<std::shared_ptr<Transaction>> StageReplaceTable(
154-
const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec,
155-
const std::string& location,
156-
const std::unordered_map<std::string, std::string>& properties, bool orCreate) = 0;
157-
158143
/// \brief Check whether table exists
159144
///
160145
/// \param identifier a table identifier
@@ -247,16 +232,6 @@ class ICEBERG_EXPORT Catalog {
247232
///
248233
/// \return the Transaction to create the table
249234
virtual std::unique_ptr<Transaction> StageCreate() = 0;
250-
251-
/// \brief Starts a transaction to replace the table
252-
///
253-
/// \return the Transaction to replace the table
254-
virtual std::unique_ptr<Transaction> StageReplace() = 0;
255-
256-
/// \brief Starts a transaction to create or replace the table
257-
///
258-
/// \return the Transaction to create or replace the table
259-
virtual std::unique_ptr<Transaction> StageCreateOrReplace() = 0;
260235
};
261236

262237
/// \brief Instantiate a builder to either create a table or start a create/replace

src/iceberg/catalog/memory/in_memory_catalog.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,6 @@ Result<std::shared_ptr<Transaction>> InMemoryCatalog::StageCreateTable(
404404
return NotImplemented("stage create table");
405405
}
406406

407-
Result<std::shared_ptr<Transaction>> InMemoryCatalog::StageReplaceTable(
408-
const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec,
409-
const std::string& location,
410-
const std::unordered_map<std::string, std::string>& properties, bool orCreate) {
411-
return NotImplemented("stage replace table");
412-
}
413-
414407
Result<bool> InMemoryCatalog::TableExists(const TableIdentifier& identifier) const {
415408
std::unique_lock lock(mutex_);
416409
return root_namespace_->TableExists(identifier);

src/iceberg/catalog/memory/in_memory_catalog.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ class ICEBERG_EXPORT InMemoryCatalog
8585
const std::string& location,
8686
const std::unordered_map<std::string, std::string>& properties) override;
8787

88-
Result<std::shared_ptr<Transaction>> StageReplaceTable(
89-
const TableIdentifier& identifier, const Schema& schema, const PartitionSpec& spec,
90-
const std::string& location,
91-
const std::unordered_map<std::string, std::string>& properties,
92-
bool orCreate) override;
93-
9488
Result<bool> TableExists(const TableIdentifier& identifier) const override;
9589

9690
Status DropTable(const TableIdentifier& identifier, bool purge) override;

src/iceberg/table.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const std::vector<SnapshotLogEntry>& Table::history() const {
133133
return metadata_->snapshot_log;
134134
}
135135

136-
std::shared_ptr<Transaction> Table::NewTransaction() const {
136+
std::unique_ptr<Transaction> Table::NewTransaction() const {
137137
throw NotImplemented("Table::NewTransaction is not implemented");
138138
}
139139

src/iceberg/table.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class ICEBERG_EXPORT Table {
112112
/// \brief Create a new transaction for this table
113113
///
114114
/// \return a shared pointer to the new Transaction
115-
virtual std::shared_ptr<Transaction> NewTransaction() const;
115+
virtual std::unique_ptr<Transaction> NewTransaction() const;
116116

117117
/// \brief Returns a FileIO to read and write table data and metadata files
118118
const std::shared_ptr<FileIO>& io() const;

src/iceberg/test/mock_catalog.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ class MockCatalog : public Catalog {
7171
const std::string&, (const std::unordered_map<std::string, std::string>&)),
7272
(override));
7373

74-
MOCK_METHOD((Result<std::shared_ptr<Transaction>>), StageReplaceTable,
75-
(const TableIdentifier&, const Schema&, const PartitionSpec&,
76-
const std::string&, (const std::unordered_map<std::string, std::string>&),
77-
bool),
78-
(override));
79-
8074
MOCK_METHOD(Result<bool>, TableExists, (const TableIdentifier&), (const, override));
8175

8276
MOCK_METHOD(Status, DropTable, (const TableIdentifier&, bool), (override));

src/iceberg/transaction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ICEBERG_EXPORT Transaction {
5151
/// \return Status::OK if all updates were queued successfully
5252
virtual Status UpdateTable(
5353
const std::vector<std::unique_ptr<TableRequirement>>& requirements,
54-
std::vector<std::unique_ptr<TableUpdate>> updates) = 0;
54+
const std::vector<std::unique_ptr<TableUpdate>>& updates) = 0;
5555

5656
/// \brief Apply the pending changes from all actions and commit
5757
///

0 commit comments

Comments
 (0)