This is an automated email from the ASF dual-hosted git repository.
gangwu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-cpp.git
The following commit(s) were added to refs/heads/main by this push:
new b1384a17 refactor: clean TableBuilder in catalog (#366)
b1384a17 is described below
commit b1384a1784cd8cb7a4453a6e9bc9fe9306988f8f
Author: lishuxu <[email protected]>
AuthorDate: Fri Nov 28 22:18:12 2025 +0800
refactor: clean TableBuilder in catalog (#366)
---
src/iceberg/catalog.h | 58 -------------------------
src/iceberg/catalog/memory/in_memory_catalog.cc | 6 ---
src/iceberg/catalog/memory/in_memory_catalog.h | 3 --
src/iceberg/catalog/rest/rest_catalog.cc | 6 ---
src/iceberg/catalog/rest/rest_catalog.h | 3 --
src/iceberg/test/mock_catalog.h | 3 --
6 files changed, 79 deletions(-)
diff --git a/src/iceberg/catalog.h b/src/iceberg/catalog.h
index d033199c..6c4957ad 100644
--- a/src/iceberg/catalog.h
+++ b/src/iceberg/catalog.h
@@ -184,64 +184,6 @@ class ICEBERG_EXPORT Catalog {
/// \return a Table instance or ErrorKind::kAlreadyExists if the table
already exists
virtual Result<std::shared_ptr<Table>> RegisterTable(
const TableIdentifier& identifier, const std::string&
metadata_file_location) = 0;
-
- /// \brief A builder used to create valid tables or start create/replace
transactions
- class TableBuilder {
- public:
- virtual ~TableBuilder() = default;
-
- /// \brief Sets a partition spec for the table
- ///
- /// \param spec a partition spec
- /// \return this for method chaining
- virtual TableBuilder& WithPartitionSpec(const PartitionSpec& spec) = 0;
-
- /// \brief Sets a sort order for the table
- ///
- /// \param sort_order a sort order
- /// \return this for method chaining
- virtual TableBuilder& WithSortOrder(const SortOrder& sort_order) = 0;
-
- /// \brief Sets a location for the table
- ///
- /// \param location a location
- /// \return this for method chaining
- virtual TableBuilder& WithLocation(const std::string& location) = 0;
-
- /// \brief Adds key/value properties to the table
- ///
- /// \param properties key/value properties
- /// \return this for method chaining
- virtual TableBuilder& WithProperties(
- const std::unordered_map<std::string, std::string>& properties) = 0;
-
- /// \brief Adds a key/value property to the table
- ///
- /// \param key a key
- /// \param value a value
- /// \return this for method chaining
- virtual TableBuilder& WithProperty(const std::string& key,
- const std::string& value) = 0;
-
- /// \brief Creates the table
- ///
- /// \return the created table
- virtual std::unique_ptr<Table> Create() = 0;
-
- /// \brief Starts a transaction to create the table
- ///
- /// \return the Transaction to create the table
- virtual std::unique_ptr<Transaction> StageCreate() = 0;
- };
-
- /// \brief Instantiate a builder to either create a table or start a
create/replace
- /// transaction
- ///
- /// \param identifier a table identifier
- /// \param schema a schema
- /// \return the builder to create a table or start a create/replace
transaction
- virtual std::unique_ptr<TableBuilder> BuildTable(const TableIdentifier&
identifier,
- const Schema& schema) const
= 0;
};
} // namespace iceberg
diff --git a/src/iceberg/catalog/memory/in_memory_catalog.cc
b/src/iceberg/catalog/memory/in_memory_catalog.cc
index 753c3358..ebc49010 100644
--- a/src/iceberg/catalog/memory/in_memory_catalog.cc
+++ b/src/iceberg/catalog/memory/in_memory_catalog.cc
@@ -417,7 +417,6 @@ Status InMemoryCatalog::DropTable(const TableIdentifier&
identifier, bool purge)
Status InMemoryCatalog::RenameTable(const TableIdentifier& from,
const TableIdentifier& to) {
- std::unique_lock lock(mutex_);
return NotImplemented("rename table");
}
@@ -454,9 +453,4 @@ Result<std::shared_ptr<Table>>
InMemoryCatalog::RegisterTable(
return LoadTable(identifier);
}
-std::unique_ptr<Catalog::TableBuilder> InMemoryCatalog::BuildTable(
- const TableIdentifier& identifier, const Schema& schema) const {
- throw IcebergError("not implemented");
-}
-
} // namespace iceberg
diff --git a/src/iceberg/catalog/memory/in_memory_catalog.h
b/src/iceberg/catalog/memory/in_memory_catalog.h
index 069a1d00..5d1f2e13 100644
--- a/src/iceberg/catalog/memory/in_memory_catalog.h
+++ b/src/iceberg/catalog/memory/in_memory_catalog.h
@@ -97,9 +97,6 @@ class ICEBERG_EXPORT InMemoryCatalog
const TableIdentifier& identifier,
const std::string& metadata_file_location) override;
- std::unique_ptr<TableBuilder> BuildTable(const TableIdentifier& identifier,
- const Schema& schema) const
override;
-
private:
std::string catalog_name_;
std::unordered_map<std::string, std::string> properties_;
diff --git a/src/iceberg/catalog/rest/rest_catalog.cc
b/src/iceberg/catalog/rest/rest_catalog.cc
index dff52e2a..e4553ace 100644
--- a/src/iceberg/catalog/rest/rest_catalog.cc
+++ b/src/iceberg/catalog/rest/rest_catalog.cc
@@ -194,10 +194,4 @@ Result<std::shared_ptr<Table>> RestCatalog::RegisterTable(
return NotImplemented("Not implemented");
}
-std::unique_ptr<RestCatalog::TableBuilder> RestCatalog::BuildTable(
- [[maybe_unused]] const TableIdentifier& identifier,
- [[maybe_unused]] const Schema& schema) const {
- return nullptr;
-}
-
} // namespace iceberg::rest
diff --git a/src/iceberg/catalog/rest/rest_catalog.h
b/src/iceberg/catalog/rest/rest_catalog.h
index 84ab2b9c..4e191e86 100644
--- a/src/iceberg/catalog/rest/rest_catalog.h
+++ b/src/iceberg/catalog/rest/rest_catalog.h
@@ -96,9 +96,6 @@ class ICEBERG_REST_EXPORT RestCatalog : public Catalog {
const TableIdentifier& identifier,
const std::string& metadata_file_location) override;
- std::unique_ptr<RestCatalog::TableBuilder> BuildTable(
- const TableIdentifier& identifier, const Schema& schema) const override;
-
private:
RestCatalog(std::unique_ptr<RestCatalogProperties> config,
std::unique_ptr<ResourcePaths> paths);
diff --git a/src/iceberg/test/mock_catalog.h b/src/iceberg/test/mock_catalog.h
index 7c54ebac..46f01c8d 100644
--- a/src/iceberg/test/mock_catalog.h
+++ b/src/iceberg/test/mock_catalog.h
@@ -83,9 +83,6 @@ class MockCatalog : public Catalog {
MOCK_METHOD((Result<std::shared_ptr<Table>>), RegisterTable,
(const TableIdentifier&, const std::string&), (override));
-
- MOCK_METHOD((std::unique_ptr<TableBuilder>), BuildTable,
- (const TableIdentifier&, const Schema&), (const, override));
};
} // namespace iceberg