{"record":{"id":"488c68ca077c0492","repo":"apache/iceberg","slug":"s-is-not-empty-s","errorCode":null,"errorMessage":"%s is not empty: %s","messagePattern":"(.+?) is not empty: (.+?)","errorType":"exception","errorClass":"NamespaceNotEmptyException","httpStatus":null,"severity":"error","filePath":"bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryMetastoreClientImpl.java","lineNumber":219,"sourceCode":"\n  @Override\n  public void delete(DatasetReference datasetReference) {\n    try {\n      HttpResponse response =\n          client\n              .datasets()\n              .delete(datasetReference.getProjectId(), datasetReference.getDatasetId())\n              .executeUnparsed();\n      if (response.getStatusCode() == HttpStatusCodes.STATUS_CODE_NOT_FOUND) {\n        throw new NoSuchNamespaceException(\n            \"Namespace does not exist: %s\", datasetReference.getDatasetId());\n      }\n\n      convertExceptionIfUnsuccessful(response);\n    } catch (IOException e) {\n      throw new RuntimeIOException(e);\n    } catch (NamespaceNotEmptyException e) {\n      throw new NamespaceNotEmptyException(\n          \"%s is not empty: %s\", datasetReference.getDatasetId(), e.getMessage());\n    }\n  }\n\n  @Override\n  public boolean setParameters(DatasetReference datasetReference, Map<String, String> parameters) {\n    Dataset dataset = load(datasetReference);\n    ExternalCatalogDatasetOptions existingOptions = dataset.getExternalCatalogDatasetOptions();\n\n    Map<String, String> existingParameters =\n        (existingOptions == null || existingOptions.getParameters() == null)\n            ? Maps.newHashMap() // Use HashMap to allow modification below\n            : Maps.newHashMap(existingOptions.getParameters()); // Copy to compare later\n\n    // Calculate what the new parameters would be.\n    Map<String, String> newParameters = Maps.newHashMap(existingParameters);\n    newParameters.putAll(parameters);\n","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryMetastoreClientImpl.java#L201-L237","documentation":"NamespaceNotEmptyException from BigQueryMetastoreClientImpl.delete wrapping the upstream BigQuery error when a dataset cannot be deleted because it still contains tables. The client rethrows with the dataset id plus the original message so the caller knows why the drop failed.","triggerScenarios":"Calling dropNamespace / client.delete on a dataset that still holds tables (Iceberg or non-Iceberg), where BigQuery refuses datasets.delete and the response surfaces a 'not empty' condition.","commonSituations":"dropNamespace without purge on a namespace that still has registered tables, leftover non-Iceberg tables inside the dataset, failed earlier table drops leaving orphans.","solutions":["Drop all tables first (catalog.listTables then dropTable each) before dropping the namespace","Use catalog.dropNamespace(ns, true) purge semantics if you intend recursive deletion where supported","Inspect the dataset in BigQuery console for foreign tables blocking deletion","Catch NamespaceNotEmptyException in teardown scripts and handle cleanup explicitly"],"exampleFix":"// before\ncatalog.dropNamespace(ns); // throws if dataset has tables\n// after\nfor (TableIdentifier t : catalog.listTables(ns)) {\n  catalog.dropTable(t);\n}\ncatalog.dropNamespace(ns);","handlingStrategy":"validation","validationCode":"boolean empty = catalog.listTables(ns).isEmpty(); if (!empty) { /* drop tables first */ }","typeGuard":null,"tryCatchPattern":"try { catalog.dropNamespace(ns); } catch (NamespaceNotEmptyException e) { /* clean up tables then retry */ }","preventionTips":["List and drop all tables before dropping the namespace","Look for non-Iceberg tables left in the dataset","Decide purge semantics explicitly in teardown scripts"],"tags":["bigquery","namespace","delete","not-empty"],"backgroundTag":"invalid-state-transition","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"}