@@ -244,9 +244,30 @@ Status RestCatalog::UpdateNamespaceProperties(
244244 return {};
245245}
246246
247- Result<std::vector<TableIdentifier>> RestCatalog::ListTables (
248- [[maybe_unused]] const Namespace& ns) const {
249- return NotImplemented (" Not implemented" );
247+ Result<std::vector<TableIdentifier>> RestCatalog::ListTables (const Namespace& ns) const {
248+ ICEBERG_ENDPOINT_CHECK (supported_endpoints_, Endpoint::CreateTable ());
249+
250+ ICEBERG_ASSIGN_OR_RAISE (auto path, paths_->Tables (ns));
251+ std::vector<TableIdentifier> result;
252+ std::string next_token;
253+ while (true ) {
254+ std::unordered_map<std::string, std::string> params;
255+ if (!next_token.empty ()) {
256+ params[kQueryParamPageToken ] = next_token;
257+ }
258+ ICEBERG_ASSIGN_OR_RAISE (
259+ const auto response,
260+ client_->Get (path, params, /* headers=*/ {}, *TableErrorHandler::Instance ()));
261+ ICEBERG_ASSIGN_OR_RAISE (auto json, FromJsonString (response.body ()));
262+ ICEBERG_ASSIGN_OR_RAISE (auto list_response, ListTablesResponseFromJson (json));
263+ result.insert (result.end (), list_response.identifiers .begin (),
264+ list_response.identifiers .end ());
265+ if (list_response.next_page_token .empty ()) {
266+ return result;
267+ }
268+ next_token = list_response.next_page_token ;
269+ }
270+ return result;
250271}
251272
252273Result<std::shared_ptr<Table>> RestCatalog::CreateTable (
@@ -280,10 +301,34 @@ Result<std::shared_ptr<Table>> RestCatalog::CreateTable(
280301}
281302
282303Result<std::shared_ptr<Table>> RestCatalog::UpdateTable (
283- [[maybe_unused]] const TableIdentifier& identifier,
284- [[maybe_unused]] const std::vector<std::unique_ptr<TableRequirement>>& requirements,
285- [[maybe_unused]] const std::vector<std::unique_ptr<TableUpdate>>& updates) {
286- return NotImplemented (" Not implemented" );
304+ const TableIdentifier& identifier,
305+ const std::vector<std::unique_ptr<TableRequirement>>& requirements,
306+ const std::vector<std::unique_ptr<TableUpdate>>& updates) {
307+ ICEBERG_ENDPOINT_CHECK (supported_endpoints_, Endpoint::CreateTable ());
308+ ICEBERG_ASSIGN_OR_RAISE (auto path, paths_->Table (identifier));
309+
310+ // Build request with non-owning shared_ptr (using no-op deleter)
311+ CommitTableRequest request{.identifier = identifier};
312+ request.requirements .reserve (requirements.size ());
313+ for (const auto & req : requirements) {
314+ request.requirements .emplace_back (req.get (), [](auto *) {});
315+ }
316+ request.updates .reserve (updates.size ());
317+ for (const auto & update : updates) {
318+ request.updates .emplace_back (update.get (), [](auto *) {});
319+ }
320+
321+ ICEBERG_ASSIGN_OR_RAISE (auto json_request, ToJsonString (ToJson (request)));
322+ ICEBERG_ASSIGN_OR_RAISE (
323+ const auto response,
324+ client_->Post (path, json_request, /* headers=*/ {}, *TableErrorHandler::Instance ()));
325+
326+ ICEBERG_ASSIGN_OR_RAISE (auto json, FromJsonString (response.body ()));
327+ ICEBERG_ASSIGN_OR_RAISE (auto commit_response, CommitTableResponseFromJson (json));
328+
329+ return Table::Make (identifier, commit_response.metadata ,
330+ std::move (commit_response.metadata_location ), file_io_,
331+ shared_from_this ());
287332}
288333
289334Result<std::shared_ptr<Transaction>> RestCatalog::StageCreateTable (
@@ -321,9 +366,17 @@ Result<bool> RestCatalog::TableExists(const TableIdentifier& identifier) const {
321366 client_->Head (path, /* headers=*/ {}, *TableErrorHandler::Instance ()));
322367}
323368
324- Status RestCatalog::RenameTable ([[maybe_unused]] const TableIdentifier& from,
325- [[maybe_unused]] const TableIdentifier& to) {
326- return NotImplemented (" Not implemented" );
369+ Status RestCatalog::RenameTable (const TableIdentifier& from, const TableIdentifier& to) {
370+ ICEBERG_ENDPOINT_CHECK (supported_endpoints_, Endpoint::RenameTable ());
371+ ICEBERG_ASSIGN_OR_RAISE (auto path, paths_->Rename ());
372+
373+ RenameTableRequest request{.source = from, .destination = to};
374+ ICEBERG_ASSIGN_OR_RAISE (auto json_request, ToJsonString (ToJson (request)));
375+ ICEBERG_ASSIGN_OR_RAISE (
376+ const auto response,
377+ client_->Post (path, json_request, /* headers=*/ {}, *TableErrorHandler::Instance ()));
378+
379+ return {};
327380}
328381
329382Result<std::string> RestCatalog::LoadTableInternal (
@@ -350,9 +403,26 @@ Result<std::shared_ptr<Table>> RestCatalog::LoadTable(const TableIdentifier& ide
350403}
351404
352405Result<std::shared_ptr<Table>> RestCatalog::RegisterTable (
353- [[maybe_unused]] const TableIdentifier& identifier,
354- [[maybe_unused]] const std::string& metadata_file_location) {
355- return NotImplemented (" Not implemented" );
406+ const TableIdentifier& identifier, const std::string& metadata_file_location) {
407+ ICEBERG_ENDPOINT_CHECK (supported_endpoints_, Endpoint::RegisterTable ());
408+ ICEBERG_ASSIGN_OR_RAISE (auto path, paths_->Register (identifier.ns ));
409+
410+ RegisterTableRequest request{
411+ .name = identifier.name ,
412+ .metadata_location = metadata_file_location,
413+ };
414+
415+ ICEBERG_ASSIGN_OR_RAISE (auto json_request, ToJsonString (ToJson (request)));
416+ ICEBERG_ASSIGN_OR_RAISE (
417+ const auto response,
418+ client_->Post (path, json_request, /* headers=*/ {}, *TableErrorHandler::Instance ()));
419+
420+ ICEBERG_ASSIGN_OR_RAISE (auto json, FromJsonString (response.body ()));
421+ ICEBERG_ASSIGN_OR_RAISE (auto load_result, LoadTableResultFromJson (json));
422+ auto non_const_catalog = std::const_pointer_cast<RestCatalog>(shared_from_this ());
423+ return Table::Make (identifier, load_result.metadata ,
424+ std::move (load_result.metadata_location ), file_io_,
425+ non_const_catalog);
356426}
357427
358428} // namespace iceberg::rest
0 commit comments