sagib1 opened a new pull request, #16061:
URL: https://github.com/apache/iceberg/pull/16061

   ### Summary
   This PR fixes a bug in JdbcCatalog where a parent namespace could be dropped 
even if it contained child namespaces, provided the parent had no direct tables 
or views. This behavior violates the Iceberg REST OpenAPI specification, which 
requires that a namespace must be empty of both tables and child namespaces 
before deletion.
   
   Without this fix, dropping a parent namespace results in "orphaned" 
metadata: the child namespaces and their associated tables remain in the 
database but become unreachable through standard catalog traversal, leading to 
metadata inconsistency.
   
   ### Changes
   Modified `JdbcCatalog#dropNamespace` to include a validation check using 
`listNamespaces(namespace)`.
   
   Ensured `NamespaceNotEmptyException` is thrown if the list of child 
namespaces is not empty.
   
   ### Verifying this change
   This change is a code fix and includes a new unit test in `TestJdbcCatalog`.
   
   ### Added Tests
   `TestJdbcCatalog#testDropNamespaceWithChildNamespace`: Verifies that 
`dropNamespace` throws `NamespaceNotEmptyException` when a child namespace 
exists and that the catalog state remains unchanged.
   
   ### Manual Verification
   Reproduced the issue using a local REST Catalog fixture and verified that 
the fix correctly blocks the operation:
   
   ```
   CREATE NAMESPACE n1;
   CREATE NAMESPACE n1.n2;
   CREATE TABLE n1.n2.t2 (id INT) USING iceberg;
   
   -- Prior to fix: Succeeded and orphaned n1.n2
   -- After fix: Throws NamespaceNotEmptyException
   DROP NAMESPACE n1;
   ```
   
   ### Documentation
   Does this pull request introduce a new feature? **No**
   
   Does this pull request introduce a breaking change? **No** (It enforces an 
existing specification contract that was being bypassed).
   
   Is any documentation update required? **No**


-- 
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]

Reply via email to