{"record":{"id":"fe8c3d29f10f26d7","repo":"apache/iceberg","slug":"cannot-drop-namespace-s-because-it-still-contains-fe8c3d","errorCode":null,"errorMessage":"Cannot drop namespace %s because it still contains non-Iceberg tables","messagePattern":"Cannot drop namespace (.+?) because it still contains non-Iceberg tables","errorType":"exception","errorClass":"NamespaceNotEmptyException","httpStatus":null,"severity":"error","filePath":"aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java","lineNumber":574,"sourceCode":"  public boolean dropNamespace(Namespace namespace) throws NamespaceNotEmptyException {\n    namespaceExists(namespace);\n\n    GetTablesResponse response =\n        glue.getTables(\n            GetTablesRequest.builder()\n                .catalogId(awsProperties.glueCatalogId())\n                .databaseName(\n                    IcebergToGlueConverter.toDatabaseName(\n                        namespace, awsProperties.glueCatalogSkipNameValidation()))\n                .build());\n\n    if (response.hasTableList() && !response.tableList().isEmpty()) {\n      Table table = response.tableList().get(0);\n      if (isGlueIcebergTable(table)) {\n        throw new NamespaceNotEmptyException(\n            \"Cannot drop namespace %s because it still contains Iceberg tables\", namespace);\n      } else {\n        throw new NamespaceNotEmptyException(\n            \"Cannot drop namespace %s because it still contains non-Iceberg tables\", namespace);\n      }\n    }\n\n    glue.deleteDatabase(\n        DeleteDatabaseRequest.builder()\n            .catalogId(awsProperties.glueCatalogId())\n            .name(\n                IcebergToGlueConverter.toDatabaseName(\n                    namespace, awsProperties.glueCatalogSkipNameValidation()))\n            .build());\n    LOG.info(\"Dropped namespace: {}\", namespace);\n    // Always successful, otherwise exception is thrown\n    return true;\n  }\n\n  @Override\n  public boolean setProperties(Namespace namespace, Map<String, String> properties)","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java#L556-L592","documentation":"GlueCatalog.dropNamespace throws NamespaceNotEmptyException when the Glue database contains tables that are not Iceberg tables (isGlueIcebergTable returns false). Iceberg's Glue catalog guards against destroying a database holding foreign-engine tables (e.g. Hive, Spark-native) that it does not own.","triggerScenarios":"Calling catalog.dropNamespace(ns) on a Glue database that contains tables created by other engines or frameworks — tables lacking Iceberg's table_type=ICEBERG parameters.","commonSituations":"Shared Glue databases used by both Hive/EMR workloads and Iceberg; mixed-use databases in data lakes; attempting to clean up a database with legacy non-Iceberg tables.","solutions":["Migrate or remove the non-Iceberg tables first, then retry dropNamespace.","If the non-Iceberg tables are known junk, delete them directly through the Glue API/console (AWS IAM permitting), outside the Iceberg catalog.","Use a dedicated Glue database for Iceberg tables so the guard never trips.","Verify with glue.getTables(...) which tables remain and who owns them before deleting."],"exampleFix":"// before\ncatalog.dropNamespace(Namespace.of(\"shared\")); // contains Hive tables\n\n// after\n// remove non-Iceberg tables via Glue API first\nglue.deleteTable(DeleteTableRequest.builder()\n    .databaseName(\"shared\").name(\"legacy_hive_tbl\").build());\ncatalog.dropNamespace(Namespace.of(\"shared\"));","handlingStrategy":"validation","validationCode":"// inspect Glue tables that are not Iceberg-owned before dropping the database\nGetTablesResponse r = glue.getTables(GetTablesRequest.builder().databaseName(db).build());\nList<Table> foreign = r.tableList().stream()\n    .filter(t -> !\"ICEBERG\".equals(t.parameters().get(\"table_type\")))\n    .collect(Collectors.toList());\nif (!foreign.isEmpty()) {\n  throw new IllegalStateException(\"Non-Iceberg tables present: \" + foreign.stream().map(Table::name).toList());\n}","typeGuard":null,"tryCatchPattern":"try {\n  catalog.dropNamespace(ns);\n} catch (NamespaceNotEmptyException e) {\n  LOG.error(\"Database contains non-Iceberg tables; remove them via Glue API first\");\n}","preventionTips":["Keep Iceberg and non-Iceberg tables in separate Glue databases","Audit database contents with glue.getTables before dropping namespaces","Migrate legacy Hive tables before teardown"],"tags":["aws","glue","namespace","not-empty","non-iceberg"],"backgroundTag":"namespace-not-empty","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}