{"record":{"id":"b7bf2213c1b42170","repo":"apache/iceberg","slug":"namespaces-are-not-supported-by-catalog-catalog-b7bf22","errorCode":null,"errorMessage":"Namespaces are not supported by catalog: ${catalogName}","messagePattern":"Namespaces are not supported by catalog: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":526,"sourceCode":"\n  @Override\n  public void createNamespace(String[] namespace, Map<String, String> metadata)\n      throws NamespaceAlreadyExistsException {\n    if (asNamespaceCatalog != null) {\n      try {\n        if (asNamespaceCatalog instanceof HadoopCatalog\n            && DEFAULT_NS_KEYS.equals(metadata.keySet())) {\n          // Hadoop catalog will reject metadata properties, but Spark automatically adds \"owner\".\n          // If only the automatic properties are present, replace metadata with an empty map.\n          asNamespaceCatalog.createNamespace(Namespace.of(namespace), ImmutableMap.of());\n        } else {\n          asNamespaceCatalog.createNamespace(Namespace.of(namespace), metadata);\n        }\n      } catch (AlreadyExistsException e) {\n        throw new NamespaceAlreadyExistsException(namespace);\n      }\n    } else {\n      throw new UnsupportedOperationException(\n          \"Namespaces are not supported by catalog: \" + catalogName);\n    }\n  }\n\n  @Override\n  public void alterNamespace(String[] namespace, NamespaceChange... changes)\n      throws NoSuchNamespaceException {\n    if (asNamespaceCatalog != null) {\n      Map<String, String> updates = Maps.newHashMap();\n      Set<String> removals = Sets.newHashSet();\n      for (NamespaceChange change : changes) {\n        if (change instanceof NamespaceChange.SetProperty) {\n          NamespaceChange.SetProperty set = (NamespaceChange.SetProperty) change;\n          updates.put(set.property(), set.value());\n        } else if (change instanceof NamespaceChange.RemoveProperty) {\n          removals.add(((NamespaceChange.RemoveProperty) change).property());\n        } else {\n          throw new UnsupportedOperationException(","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L508-L544","documentation":"Thrown by SparkCatalog.createNamespace when the underlying Iceberg catalog does not implement SupportsNamespaces (asNamespaceCatalog is null). Namespaces are a capability of the catalog, and this catalog cannot create them, so an UnsupportedOperationException naming the catalog is raised.","triggerScenarios":"CREATE NAMESPACE or createNamespace() against a catalog configured via spark.sql.catalog.<name> whose implementation is table-only (no SupportsNamespaces), e.g. a custom catalog or certain glue/JDBC setups lacking namespace support.","commonSituations":"Applying a generic namespace bootstrap script across heterogeneous catalogs; using an external catalog that manages its own databases/locations and disallows namespace creation from Iceberg.","solutions":["Configure a namespace-capable catalog (HiveCatalog, HadoopCatalog, REST, Nessie, JDBC)","Create the equivalent namespace/database through the external system (e.g. Hive 'CREATE DATABASE') instead of via this catalog","Skip namespace creation when SupportsNamespaces is not implemented","Document per-catalog capabilities so setup scripts branch accordingly"],"exampleFix":"// before\nspark.sql(\"CREATE NAMESPACE my_catalog.prod\")\n// after\nif (sparkCatalog instanceof SupportsNamespaces) {\n  spark.sql(\"CREATE NAMESPACE IF NOT EXISTS my_catalog.prod\");\n} else {\n  // create the database in the external metastore instead\n  hiveClient.createDatabase(\"prod\");\n}","handlingStrategy":"type-guard","validationCode":"if (!(catalog instanceof SupportsNamespaces)) {\n  throw new UnsupportedOperationException(\n      \"Namespaces are not supported by catalog: \" + catalog.name());\n}","typeGuard":"boolean canCreateNamespaces(CatalogPlugin catalog) {\n  return catalog instanceof SupportsNamespaces;\n}","tryCatchPattern":"try {\n  nsc.createNamespace(ns, metadata);\n} catch (UnsupportedOperationException e) {\n  log.error(\"Namespace creation unsupported on {}; use external metastore\", catalogName, e);\n  throw e;\n}","preventionTips":["Verify SupportsNamespaces before namespace creation logic","Route namespace provisioning to the external system (Hive metastore, Nessie) for catalogs that lack it","Configure namespace-capable catalog types in Spark config","Keep a capability matrix of catalogs used in your platform"],"tags":["spark","catalog","namespace","unsupported-operation"],"backgroundTag":"operation-not-supported","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"}