{"record":{"id":"4a96573edd8027d2","repo":"apache/iceberg","slug":"can-not-alter-the-default-database-when-the-iceber","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/v1.20/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/v1.20/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java#L294-L330","documentation":"alterDatabase on a non-NamespaceCatalog-backed Flink Iceberg catalog rejects altering the default database: since no real namespaces exist, the default database is virtual and its properties can never be persisted, so any alter fails with this CatalogException.","triggerScenarios":"Calling FlinkCatalog.alterDatabase (ALTER DATABASE ... SET PROPERTIES) where the underlying Iceberg catalog is not a NamespaceCatalog AND the target database name equals getDefaultDatabase() (usually 'default').","commonSituations":"Running ALTER DATABASE default SET ('k'='v') in Flink SQL against a table-only Iceberg catalog; application code adjusting default-namespace properties expecting Hadoop/Hive-like behavior.","solutions":["Switch to a namespace-capable Iceberg catalog implementation (HiveCatalog/HadoopCatalog/REST) if you need database properties.","Don't alter the default database — create tables directly and put properties on tables instead.","Guard code: skip alterDatabase when name equals the default database and the catalog lacks namespace support, to fail gracefully.","Store the intended settings in Flink session/dynamic table options rather than database properties."],"exampleFix":"// before\nALTER DATABASE iceberg_catalog.`default` SET ('write.format.default'='orc');\n// after: set on the table instead\nALTER TABLE iceberg_catalog.db.t1 SET ('write.format.default'='orc');","handlingStrategy":"validation","validationCode":"if (\"default\".equals(dbName) && !(catalog instanceof NamespaceCatalog)) {\n  skipAlter(); // or fail with actionable message\n}","typeGuard":"boolean canAlterDatabase(String name) {\n  return flinkCatalog.asNamespaceCatalog() != null || !flinkCatalog.getDefaultDatabase().equals(name);\n}","tryCatchPattern":"try {\n  flinkCatalog.alterDatabase(name, changes, ignoreIfNotExists);\n} catch (CatalogException e) {\n  // apply properties at table level instead\n}","preventionTips":["Don't ALTER DATABASE the default database on namespace-less catalogs.","Put settings on tables rather than the virtual default database.","Choose a namespace-capable catalog implementation when database properties are required."],"tags":["flink","catalog","namespaces"],"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"}