@@ -63,10 +63,10 @@ class ICEBERG_EXPORT InMemoryNamespace {
6363 // / \brief Deletes an existing namespace.
6464 // /
6565 // / \param namespace_ident The namespace to delete.
66- // / \return Status::OK if the namespace is deleted;
67- // / ErrorKind::kNoSuchNamespace if the namespace does not exist;
68- // / ErrorKind::kNotAllowed if the namespace is not empty.
69- Status DropNamespace (const Namespace& namespace_ident);
66+ // / \return Result<bool> indicating whether the namespace was deleted.
67+ // / Returns false if the namespace does not exist.
68+ // / Returns error if the namespace is not empty.
69+ Result< bool > DropNamespace (const Namespace& namespace_ident);
7070
7171 // / \brief Retrieves the properties of the specified namespace.
7272 // /
@@ -107,9 +107,9 @@ class ICEBERG_EXPORT InMemoryNamespace {
107107 // / \brief Unregisters a table from the specified namespace.
108108 // /
109109 // / \param table_ident The identifier of the table to unregister.
110- // / \return Status::OK if the table is removed;
111- // / ErrorKind::kNoSuchTable if the table does not exist.
112- Status UnregisterTable (const TableIdentifier& table_ident);
110+ // / \return Result<bool> indicating whether the table was unregistered.
111+ // / Returns false if the table does not exist.
112+ Result< bool > DropTable (const TableIdentifier& table_ident);
113113
114114 // / \brief Checks if a table exists in the specified namespace.
115115 // /
@@ -224,7 +224,7 @@ Status InMemoryNamespace::CreateNamespace(
224224 return {};
225225}
226226
227- Status InMemoryNamespace::DropNamespace (const Namespace& namespace_ident) {
227+ Result< bool > InMemoryNamespace::DropNamespace (const Namespace& namespace_ident) {
228228 if (namespace_ident.levels .empty ()) {
229229 return InvalidArgument (" namespace identifier is empty" );
230230 }
@@ -238,7 +238,7 @@ Status InMemoryNamespace::DropNamespace(const Namespace& namespace_ident) {
238238
239239 const auto it = parentRs.value ()->children_ .find (to_delete);
240240 if (it == parentRs.value ()->children_ .end ()) {
241- return NotFound ( " namespace {} is not found " , to_delete) ;
241+ return false ;
242242 }
243243
244244 const auto & target = it->second ;
@@ -247,7 +247,7 @@ Status InMemoryNamespace::DropNamespace(const Namespace& namespace_ident) {
247247 }
248248
249249 parentRs.value ()->children_ .erase (to_delete);
250- return {} ;
250+ return true ;
251251}
252252
253253Result<std::unordered_map<std::string, std::string>> InMemoryNamespace::GetProperties (
@@ -299,11 +299,15 @@ Status InMemoryNamespace::RegisterTable(const TableIdentifier& table_ident,
299299 return {};
300300}
301301
302- Status InMemoryNamespace::UnregisterTable (const TableIdentifier& table_ident) {
302+ Result< bool > InMemoryNamespace::DropTable (const TableIdentifier& table_ident) {
303303 const auto ns = GetNamespace (this , table_ident.ns );
304304 ICEBERG_RETURN_UNEXPECTED (ns);
305- ns.value ()->table_metadata_locations_ .erase (table_ident.name );
306- return {};
305+ const auto it = ns.value ()->table_metadata_locations_ .find (table_ident.name );
306+ if (it == ns.value ()->table_metadata_locations_ .end ()) {
307+ return false ;
308+ }
309+ ns.value ()->table_metadata_locations_ .erase (it);
310+ return true ;
307311}
308312
309313Result<bool > InMemoryNamespace::TableExists (const TableIdentifier& table_ident) const {
@@ -369,7 +373,7 @@ Result<std::vector<Namespace>> InMemoryCatalog::ListNamespaces(
369373 return root_namespace_->ListNamespaces (ns);
370374}
371375
372- Status InMemoryCatalog::DropNamespace (const Namespace& ns) {
376+ Result< bool > InMemoryCatalog::DropNamespace (const Namespace& ns) {
373377 std::unique_lock lock (mutex_);
374378 return root_namespace_->DropNamespace (ns);
375379}
@@ -453,10 +457,10 @@ Result<bool> InMemoryCatalog::TableExists(const TableIdentifier& identifier) con
453457 return root_namespace_->TableExists (identifier);
454458}
455459
456- Status InMemoryCatalog::DropTable (const TableIdentifier& identifier, bool purge) {
460+ Result< bool > InMemoryCatalog::DropTable (const TableIdentifier& identifier, bool purge) {
457461 std::unique_lock lock (mutex_);
458462 // TODO(Guotao): Delete all metadata files if purge is true.
459- return root_namespace_->UnregisterTable (identifier);
463+ return root_namespace_->DropTable (identifier);
460464}
461465
462466Status InMemoryCatalog::RenameTable (const TableIdentifier& from,
0 commit comments