{"record":{"id":"00015964ec6f1e01","repo":"apache/iceberg","slug":"can-not-alter-the-default-database-when-the-iceber-000159","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.2/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.2/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java#L294-L330","documentation":"Flink's alterDatabase was called on an Iceberg catalog whose underlying icebergCatalog does not implement NamespaceCatalog (no namespace support), and the target name is the default database. Since there is no namespace backend to alter, Iceberg refuses to silently alter the built-in default database and throws a CatalogException. This guards against operations that appear to succeed but have no real backing metadata.","triggerScenarios":"Calling FlinkCatalog.alterDatabase(ObjectPath/name, CatalogDatabase, ignoreIfNotExists) where the wrapped icebergCatalog is not a NamespaceCatalog and the database name equals getDefaultDatabase() (typically 'default'). The check at FlinkCatalog.java:311 fires before the DatabaseNotExistException fallback.","commonSituations":"Submitting Flink SQL like ALTER DATABASE `default` SET (...) while using an Iceberg catalog backed by a catalog type without namespace support (e.g. some Hive/REST/JDBC configurations where the catalog is loaded as a plain Catalog, not a NamespaceCatalog); job SQL migration from a Hive catalog to an Iceberg catalog.","solutions":["Do not run ALTER DATABASE against the default database in an Iceberg catalog without namespace support; remove the statement or apply the properties at the table level.","Configure the underlying Iceberg catalog to a namespace-supporting implementation (e.g. HiveCatalog, JdbcCatalog, REST catalog) so alterDatabase takes the NamespaceCatalog path.","If the alter is best-effort, guard the SQL: only issue ALTER DATABASE when the catalog supports namespaces and the database is not the default."],"exampleFix":"// before\nALTER DATABASE `default` SET ('table.warehouse'='/tmp/wh');\n\n// after\n-- remove the ALTER DATABASE; set properties per table instead\nCREATE TABLE t (...) WITH ('table.warehouse'='/tmp/wh');","handlingStrategy":"validation","validationCode":"if (\"default\".equals(databaseName) && !namespaceCatalogSupportsNamespaces(catalog)) {\n  throw new SkipAlterException(\"ALTER DATABASE on default db is unsupported\");\n}","typeGuard":"boolean supportsNamespaces = icebergCatalog instanceof org.apache.iceberg.catalog.NamespaceCatalog;","tryCatchPattern":null,"preventionTips":["Never issue ALTER DATABASE on the 'default' database in an Iceberg catalog.","Check that the underlying catalog implements NamespaceCatalog before database-level operations.","Prefer table-level properties over database-level properties in Iceberg."],"tags":["flink","catalog","namespace","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"}