DerGut commented on code in PR #2890:
URL: https://github.com/apache/iceberg-rust/pull/2890#discussion_r3669384291
##########
crates/iceberg/src/catalog/memory/namespace_state.rs:
##########
@@ -186,13 +186,26 @@ impl NamespaceState {
let (parent_namespace_state, child_namespace_name) =
self.get_mut_parent_namespace_of(namespace_ident)?;
- match parent_namespace_state
- .namespaces
- .remove(&child_namespace_name)
- {
- None => no_such_namespace_err(namespace_ident),
- Some(_) => Ok(()),
+ let Some(namespace_state) =
parent_namespace_state.namespaces.get(&child_namespace_name)
+ else {
+ return no_such_namespace_err(namespace_ident);
+ };
+
+ let child_namespace_count = namespace_state.namespaces.len();
+ let table_count = namespace_state.table_metadata_locations.len();
+ if child_namespace_count > 0 || table_count > 0 {
+ return Err(Error::new(
+ ErrorKind::Unexpected,
Review Comment:
`PreconditionFailed` might be a tad more fitting
```suggestion
ErrorKind::PreconditionFailed,
```
> /// The operation was rejected because the system is not in a state
required for the operation’s execution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]