ajantha-bhat commented on code in PR #10630:
URL: https://github.com/apache/iceberg/pull/10630#discussion_r1668419668


##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java:
##########
@@ -226,8 +229,32 @@ public void createNamespace(Namespace namespace, 
Map<String, String> metadata) {
       if (existing != null) {
         throw namespaceAlreadyExists(key, existing, null);
       }
+
+      // check if the parent namespace exists
+      List<ContentKey> keys = new ArrayList<>(namespace.levels().length);
+      Map<ContentKey, Content> contentInfo = new HashMap<>();
+      for (int i = 0; i < namespace.levels().length - 1; i++) {
+        Namespace parent = Namespace.of(Arrays.copyOf(namespace.levels(), i + 
1));
+        ContentKey parentKey = ContentKey.of(parent.levels());
+        keys.add(parentKey);
+        Content c = 
api.getContent().reference(getReference()).key(parentKey).get().get(parentKey);
+        contentInfo.put(parentKey, c);
+      }
+
+
+      ArrayList<Operation.Put> putOperations = new ArrayList<>(keys.size());
+      for (Map.Entry<ContentKey, Content> contentKeyContentEntry : 
contentInfo.entrySet()) {
+        if (contentKeyContentEntry.getValue() == null) {
+          org.projectnessie.model.Namespace parentContent =
+              org.projectnessie.model.Namespace.of(
+                  contentKeyContentEntry.getKey().getElements(), 
ImmutableMap.of());
+          putOperations.add(Operation.Put.of(contentKeyContentEntry.getKey(), 
parentContent));

Review Comment:
   If we auto create the missing parent namespaces during the current 
namespace, who will be responsible for dropping the parent namespace when we 
drop the child namespace? 
   
   So, we need to handle drop namespace as well. 
   But what if we the user current user don't have permission to drop the 
parent namespace. 



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