okumin commented on code in PR #16199:
URL: https://github.com/apache/iceberg/pull/16199#discussion_r3193288840


##########
core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java:
##########
@@ -300,18 +301,49 @@ private static <T> Pair<List<T>, String> paginate(List<T> 
list, String pageToken
     return Pair.of(subList, nextPageToken);
   }
 
+  /**
+   * @deprecated use {@link #listNamespaces(SupportsNamespaces, Namespace, 
boolean)} instead.
+   */
+  @Deprecated
   public static ListNamespacesResponse listNamespaces(
       SupportsNamespaces catalog, Namespace parent) {
+    return listNamespaces(catalog, parent, false);
+  }
+
+  public static ListNamespacesResponse listNamespaces(
+      SupportsNamespaces catalog, Namespace parent, boolean recursive) {
     List<Namespace> results;
     if (parent.isEmpty()) {
       results = catalog.listNamespaces();
     } else {
       results = catalog.listNamespaces(parent);
     }
 
+    if (recursive) {
+      results = listNamespacesRecursively(catalog, results);
+    }
+
     return ListNamespacesResponse.builder().addAll(results).build();
   }
 
+  private static List<Namespace> listNamespacesRecursively(
+      SupportsNamespaces catalog, List<Namespace> namespaces) {
+    List<Namespace> allNamespaces = Lists.newArrayList(namespaces);
+
+    for (Namespace namespace : namespaces) {
+      try {
+        List<Namespace> children = catalog.listNamespaces(namespace);
+        if (!children.isEmpty()) {
+          allNamespaces.addAll(listNamespacesRecursively(catalog, children));
+        }
+      } catch (NoSuchNamespaceException e) {
+        // Namespace may have been deleted concurrently, skip it
+      }

Review Comment:
   Though I'm not confident with the authz semantics against nested namespaces, 
can this properly handle the case where 403 Forbidden happens?



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