diff --git a/api/src/main/java/org/apache/iceberg/catalog/SessionCatalog.java b/api/src/main/java/org/apache/iceberg/catalog/SessionCatalog.java index 157a4993706d..fe29f8918531 100644 --- a/api/src/main/java/org/apache/iceberg/catalog/SessionCatalog.java +++ b/api/src/main/java/org/apache/iceberg/catalog/SessionCatalog.java @@ -270,21 +270,40 @@ default void createNamespace(SessionContext context, Namespace namespace) { * method must return ["a"] in the result array. * * @param context session context - * @return an List of namespace {@link Namespace} names + * @return a List of namespace {@link Namespace} names */ default List listNamespaces(SessionContext context) { return listNamespaces(context, Namespace.empty()); } /** - * List namespaces from the namespace. + * List child namespaces from the namespace. + * + *

For two existing tables named 'a.b.c.table' and 'a.b.d.table', this method returns: + * + *

* - *

For example, if table a.b.t exists, use 'SELECT NAMESPACE IN a' this method must return - * Namepace.of("a","b") {@link Namespace}. + *

+ * + * + * + * * * @param context session context * @param namespace a {@link Namespace namespace} - * @return a List of namespace {@link Namespace} names + * @return a List of child {@link Namespace} names from the given namespace * @throws NoSuchNamespaceException If the namespace does not exist (optional) */ List listNamespaces(SessionContext context, Namespace namespace); diff --git a/api/src/main/java/org/apache/iceberg/catalog/SupportsNamespaces.java b/api/src/main/java/org/apache/iceberg/catalog/SupportsNamespaces.java index 14cece611f76..7c3af5fe5745 100644 --- a/api/src/main/java/org/apache/iceberg/catalog/SupportsNamespaces.java +++ b/api/src/main/java/org/apache/iceberg/catalog/SupportsNamespaces.java @@ -68,19 +68,38 @@ default void createNamespace(Namespace namespace) { * exist and must be returned by this discovery method. For example, if table a.b.t exists, this * method must return ["a"] in the result array. * - * @return an List of namespace {@link Namespace} names + * @return a List of namespace {@link Namespace} names */ default List listNamespaces() { return listNamespaces(Namespace.empty()); } /** - * List namespaces from the namespace. + * List child namespaces from the namespace. * - *

For example, if table a.b.t exists, use 'SELECT NAMESPACE IN a' this method must return - * Namepace.of("a","b") {@link Namespace}. + *

For two existing tables named 'a.b.c.table' and 'a.b.d.table', this method returns: * - * @return a List of namespace {@link Namespace} names + *

    + *
  • Given: {@code Namespace.empty()} + *
  • Returns: {@code Namespace.of("a")} + *
+ * + *
    + *
  • Given: {@code Namespace.of("a")} + *
  • Returns: {@code Namespace.of("a", "b")} + *
+ * + *
    + *
  • Given: {@code Namespace.of("a", "b")} + *
  • Returns: {@code Namespace.of("a", "b", "c")} and {@code Namespace.of("a", "b", "d")} + *
+ * + *
    + *
  • Given: {@code Namespace.of("a", "b", "c")} + *
  • Returns: empty list, because there are no child namespaces + *
+ * + * @return a List of child {@link Namespace} names from the given namespace * @throws NoSuchNamespaceException If the namespace does not exist (optional) */ List listNamespaces(Namespace namespace) throws NoSuchNamespaceException; diff --git a/open-api/rest-catalog-open-api.yaml b/open-api/rest-catalog-open-api.yaml index a474d7c49f0e..2de99a751777 100644 --- a/open-api/rest-catalog-open-api.yaml +++ b/open-api/rest-catalog-open-api.yaml @@ -194,8 +194,10 @@ paths: summary: List namespaces, optionally providing a parent namespace to list underneath description: List all namespaces at a certain level, optionally starting from a given parent namespace. - For example, if table accounting.tax.paid exists, using 'SELECT NAMESPACE IN accounting' would - translate into `GET /namespaces?parent=accounting` and must return a namespace, ["accounting", "tax"]. + If table accounting.tax.paid.info exists, using 'SELECT NAMESPACE IN accounting' would + translate into `GET /namespaces?parent=accounting` and must return a namespace, ["accounting", "tax"] only. + Using 'SELECT NAMESPACE IN accounting.tax' would + translate into `GET /namespaces?parent=accounting%1Ftax` and must return a namespace, ["accounting", "tax", "paid"]. If `parent` is not provided, all top-level namespaces should be listed. operationId: listNamespaces parameters: