{"record":{"id":"6cc49d39f20354de","repo":"apache/iceberg","slug":"namespaces-are-not-supported-by-catalog-6cc49d","errorCode":null,"errorMessage":"Namespaces are not supported by catalog: ","messagePattern":"Namespaces are not supported by catalog: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java","lineNumber":232,"sourceCode":"  public void createDatabase(String name, CatalogDatabase database, boolean ignoreIfExists)\n      throws DatabaseAlreadyExistException, CatalogException {\n    createDatabase(\n        name, mergeComment(database.getProperties(), database.getComment()), ignoreIfExists);\n  }\n\n  private void createDatabase(\n      String databaseName, Map<String, String> metadata, boolean ignoreIfExists)\n      throws DatabaseAlreadyExistException, CatalogException {\n    if (asNamespaceCatalog != null) {\n      try {\n        asNamespaceCatalog.createNamespace(appendLevel(baseNamespace, databaseName), metadata);\n      } catch (AlreadyExistsException e) {\n        if (!ignoreIfExists) {\n          throw new DatabaseAlreadyExistException(getName(), databaseName, e);\n        }\n      }\n    } else {\n      throw new UnsupportedOperationException(\n          \"Namespaces are not supported by catalog: \" + getName());\n    }\n  }\n\n  private Map<String, String> mergeComment(Map<String, String> metadata, String comment) {\n    Map<String, String> ret = Maps.newHashMap(metadata);\n    if (metadata.containsKey(\"comment\")) {\n      throw new CatalogException(\"Database properties should not contain key: 'comment'.\");\n    }\n\n    if (!StringUtils.isNullOrWhitespaceOnly(comment)) {\n      ret.put(\"comment\", comment);\n    }\n    return ret;\n  }\n\n  @Override\n  public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade)","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java#L214-L250","documentation":"FlinkCatalog throws UnsupportedOperationException with message 'Namespaces are not supported by catalog: <name>' when createDatabase is invoked but the underlying Iceberg catalog does not implement NamespaceCatalog (asNamespaceCatalog == null). Such catalogs only expose the single default database, so creating databases is impossible.","triggerScenarios":"CREATE DATABASE x (or catalog.createDatabase) against a FlinkCatalog wrapping a non-namespace Iceberg catalog (asNamespaceCatalog == null) — this branch always throws regardless of the name.","commonSituations":"Configuring the Flink Iceberg catalog with a custom Catalog implementation lacking namespace support; users then attempt to organize tables into databases.","solutions":["Switch to an Iceberg catalog implementing NamespaceCatalog (HiveCatalog, HadoopCatalog, RESTCatalog, JdbcCatalog, NessieCatalog)","Use the single default database the non-namespace catalog exposes instead of creating new databases","Implement NamespaceCatalog in your custom catalog if you need multi-database support"],"exampleFix":"// before\nCREATE DATABASE db1; // UnsupportedOperationException\n// after\n// load a namespace-capable catalog\nCatalog iceberg = CatalogLoader.loadCatalog(\"hadoop\", warehousePath, props, hadoopConf);\nCREATE DATABASE db1;","handlingStrategy":"fallback","validationCode":"boolean supportsNamespaces = icebergCatalog instanceof NamespaceCatalog; if (!supportsNamespaces) { /* restrict to default db */ }","typeGuard":"NamespaceCatalog asNs = (icebergCatalog instanceof NamespaceCatalog ns) ? ns : null;","tryCatchPattern":"try { catalog.createDatabase(name, props, false); } catch (UnsupportedOperationException e) { LOG.warn(\"Catalog {} has no namespace support; using default db\", catalog.getName()); }","preventionTips":["Verify the chosen catalog type supports namespaces before DDL","Document that non-namespace catalogs expose exactly one database","Prefer HiveCatalog/RESTCatalog/JdbcCatalog/HadoopCatalog for multi-database workloads"],"tags":["flink","catalog","unsupported-operation","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"}