{"record":{"id":"9ef4c1144cc8bfdf","repo":"apache/iceberg","slug":"namespaces-are-not-supported-by-catalog-9ef4c1","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.1/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.1/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java#L214-L250","documentation":"FlinkCatalog throws this UnsupportedOperationException when a namespace operation is attempted against an Iceberg catalog that only supports the single default database (i.e. it does not implement the NamespaceBackend/SupportsNamespaces interface, such as a plain Hadoop-free or Hive-less catalog). createDatabase cannot create a new database, so it fails fast instead of silently misbehaving.","triggerScenarios":"Calling catalog.createDatabase(name, ignoreIfExists) when the underlying Iceberg Catalog implementation does not support namespaces (supportsNamespaces() returns false), e.g. using HadoopCatalog-style behavior or a custom catalog without namespace support.","commonSituations":"Users switching from a Hive or Hadoop catalog that supported databases to a catalog where only the default database exists; SQL scripts with CREATE DATABASE executed against an iceberg catalog configured without namespace support; migration tooling assuming all catalogs support namespaces.","solutions":["Do not create additional databases; use the default database for all tables","Configure a catalog implementation that supports namespaces (e.g. HiveCatalog or JDBC/Hadoop catalog with namespace support)","Wrap createDatabase in a capability check: only call it when ((SupportsNamespaces) catalog).supportsNamespaces() is true","Catch UnsupportedOperationException/CatalogException and treat as 'database already exists/default only' if the app tolerates it"],"exampleFix":"// before\nflinkCatalog.createDatabase(\"analytics\", props, false);\n// after\nif (flinkCatalog instanceof SupportsNamespaces && ((SupportsNamespaces) flinkCatalog).supportsNamespaces()) {\n  flinkCatalog.createDatabase(\"analytics\", props, false);\n} else {\n  // use default database\n}","handlingStrategy":"validation","validationCode":"if (!(catalog instanceof SupportsNamespaces ns) || !ns.supportsNamespaces()) {\n  throw new IllegalStateException(\"Catalog does not support namespaces; use the default database\");\n}","typeGuard":"boolean supportsNamespaces = catalog instanceof SupportsNamespaces && ((SupportsNamespaces) catalog).supportsNamespaces();","tryCatchPattern":"try { catalog.createDatabase(name, props, false); } catch (UnsupportedOperationException | CatalogException e) { log.warn(\"Namespaces unsupported, using default database\"); }","preventionTips":["Check supportsNamespaces() before any database DDL","Only use the default database with non-namespace catalogs","Prefer Hive/JDBC catalogs when multi-database layout is required"],"tags":["flink","iceberg-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-14T11:17:12.474Z"}