{"record":{"id":"5f3f0654a11b32d4","repo":"apache/iceberg","slug":"can-not-alter-the-default-database-when-the-iceber-5f3f06","errorCode":null,"errorMessage":"Can not alter the default database when the iceberg catalog doesn't support namespaces.","messagePattern":"Can not alter the default database when the iceberg catalog doesn't support namespaces\\.","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java","lineNumber":312,"sourceCode":"          }\n        }\n\n        if (!updates.isEmpty()) {\n          asNamespaceCatalog.setProperties(namespace, updates);\n        }\n\n        if (!removals.isEmpty()) {\n          asNamespaceCatalog.removeProperties(namespace, removals);\n        }\n\n      } catch (NoSuchNamespaceException e) {\n        if (!ignoreIfNotExists) {\n          throw new DatabaseNotExistException(getName(), name, e);\n        }\n      }\n    } else {\n      if (getDefaultDatabase().equals(name)) {\n        throw new CatalogException(\n            \"Can not alter the default database when the iceberg catalog doesn't support namespaces.\");\n      }\n      if (!ignoreIfNotExists) {\n        throw new DatabaseNotExistException(getName(), name);\n      }\n    }\n  }\n\n  @Override\n  public List<String> listTables(String databaseName)\n      throws DatabaseNotExistException, CatalogException {\n    try {\n      return icebergCatalog.listTables(appendLevel(baseNamespace, databaseName)).stream()\n          .map(TableIdentifier::name)\n          .collect(Collectors.toList());\n    } catch (NoSuchNamespaceException e) {\n      throw new DatabaseNotExistException(getName(), databaseName, e);\n    }","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java#L294-L330","documentation":"When the underlying Iceberg catalog does not support namespaces, alterDatabase cannot operate on any database except reporting 'not exists' — but the default database always exists, so altering it would be meaningless. The library throws CatalogException to make this case explicit rather than silently succeeding.","triggerScenarios":"Calling alterDatabase(name, ...) where name equals the default database name (getDefaultDatabase()) on a catalog that does not support namespaces.","commonSituations":"Flink SQL ALTER DATABASE on the default database of an iceberg catalog without namespace support; automated schema-management jobs iterating all databases including the default one.","solutions":["Skip the default database in alter-database automation","Use a namespace-capable catalog (Hive/JDBC) if altering databases is required","Guard with a supportsNamespaces() capability check before calling alterDatabase"],"exampleFix":"// before\ncatalog.alterDatabase(catalog.getDefaultDatabase(), changes, false);\n// after\nif (!name.equals(catalog.getDefaultDatabase())) {\n  catalog.alterDatabase(name, changes, false);\n}","handlingStrategy":"validation","validationCode":"if (catalog.getDefaultDatabase().equals(name)) {\n  return; // skip altering default database\n}","typeGuard":"null","tryCatchPattern":"try { catalog.alterDatabase(name, changes, false); } catch (CatalogException e) { log.warn(\"Skip default database alter: {}\", name); }","preventionTips":["Exclude the default database from automated alter loops","Use a namespace-capable catalog if database alteration is a requirement"],"tags":["flink","iceberg-catalog","default-database","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}