{"record":{"id":"6cabfffb2744b74f","repo":"apache/iceberg","slug":"namespaces-are-not-supported-by-catalog","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/v1.20/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/v1.20/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java#L214-L250","documentation":"FlinkCatalog.createDatabase throws UnsupportedOperationException when the underlying Iceberg catalog is not a NamespaceCatalog (e.g. a plain TableCatalog like Hadoop/Hive in table-only mode) — such catalogs have no database concept, so namespace creation cannot be forwarded.","triggerScenarios":"CREATE DATABASE on an Iceberg Flink catalog instance backed by a catalog that does not implement NamespaceCatalog (asNamespaceCatalog == null), e.g. the default 'iceberg' catalog without namespace support configured.","commonSituations":"Running CREATE DATABASE my_db against an Iceberg catalog wired to a table-only backend; switching the catalog implementation (REST/Hadoop) and forgetting that only NamespaceCatalog implementations accept databases; using the default database-only catalog in Flink SQL.","solutions":["Configure the Flink Iceberg catalog with a namespace-capable implementation (HadoopCatalog, HiveCatalog, REST catalog with namespaces).","Don't create databases — use only the default database (tables go directly under the catalog).","Check catalog type in code: only call createDatabase when the wrapped catalog implements NamespaceCatalog.","Set catalog properties so the Iceberg catalog resolves to a NamespaceCatalog implementation."],"exampleFix":"// before\nCREATE DATABASE iceberg_catalog.my_db;\n// after: only with a namespace-capable catalog, or use default db\nCREATE TABLE iceberg_catalog.my_db.t1 (...);","handlingStrategy":"type-guard","validationCode":"if (!(flinkCatalog.getWrappedCatalog() instanceof NamespaceCatalog)) {\n  throw new UnsupportedOperationException(\"CREATE DATABASE unsupported for this Iceberg catalog\");\n}","typeGuard":"boolean supportsNamespaces(FlinkCatalog c) { return c.asNamespaceCatalog() != null; }","tryCatchPattern":"try {\n  flinkCatalog.createDatabase(name, props, ignoreIfExists);\n} catch (UnsupportedOperationException e) {\n  // fall back to default database or reconfigure catalog\n}","preventionTips":["Use HiveCatalog/HadoopCatalog/REST catalog when databases are needed.","Avoid CREATE DATABASE DDL against table-only catalogs.","Document catalog capabilities for SQL users."],"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"}