public void dropNamespaceCascade()

in polaris-synchronizer/api/src/main/java/org/apache/polaris/tools/sync/polaris/service/impl/PolarisIcebergCatalogService.java [111:138]


    public void dropNamespaceCascade(Namespace namespace) {
        List<Namespace> allChildNamespaces = this.listAllChildNamespaces(namespace);

        List<TableIdentifier> tables = new ArrayList<>();

        for (Namespace childNamespace : allChildNamespaces) {
            tables.addAll(this.catalog.listTables(childNamespace));
        }

        if (!namespace.isEmpty()) {
            tables.addAll(this.catalog.listTables(namespace));
        }

        for (TableIdentifier tableIdentifier : tables) {
            this.catalog.dropTable(tableIdentifier);
        }

        // go over in reverse order of namespaces since we discover namespaces
        // in the parent -> child order, so we need to drop all children
        // before we can drop the parent
        for (Namespace childNamespace : allChildNamespaces.reversed()) {
            this.catalog.dropNamespace(childNamespace);
        }

        if (!namespace.isEmpty()) {
            this.catalog.dropNamespace(namespace);
        }
    }