{"record":{"id":"838ae3da1c1930e1","repo":"apache/iceberg","slug":"namespaces-are-not-supported-by-catalog-s","errorCode":null,"errorMessage":"Namespaces are not supported by catalog: %s","messagePattern":"Namespaces are not supported by catalog: (.+?)","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":521,"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":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L503-L539","documentation":"SparkCatalog throws this UnsupportedOperationException when createNamespace is called but the underlying catalog does not implement NamespaceCatalog (asNamespaceCatalog is null). Not all Iceberg catalogs support hierarchical namespaces, so namespace operations are refused rather than silently misbehaving.","triggerScenarios":"CREATE NAMESPACE or ALTER NAMESPACE against a catalog configured via spark.sql.catalog.<name> whose implementation only supports flat table identifiers (no NamespaceCatalog), e.g. some custom/REST configs without namespace support.","commonSituations":"Pointing Spark at a catalog type that has no namespace concept (legacy key-value catalogs); copy-pasted catalog config where the implementation class lacks namespace support; assuming all Iceberg catalogs are hierarchical like HadoopCatalog.","solutions":["Use a catalog implementation that supports namespaces (HadoopCatalog, HiveCatalog, JDBC, REST, Nessie)","Check the configured catalog class and its supported operations before issuing namespace DDL","Keep tables in the catalog's top level if namespaces are unsupported"],"exampleFix":"// before\nspark.conf.set(\"spark.sql.catalog.custom\", \"com.example.FlatCatalog\");\nspark.sql(\"CREATE NAMESPACE custom.ns\"); // throws\n// after\nspark.conf.set(\"spark.sql.catalog.custom\", \"org.apache.iceberg.spark.SparkCatalog\");\nspark.sql(\"CREATE NAMESPACE IF NOT EXISTS custom.ns\");","handlingStrategy":"validation","validationCode":"// check capability before DDL\nboolean supportsNamespaces = catalog instanceof org.apache.iceberg.catalog.NamespaceCatalog;\nif (!supportsNamespaces) throw new IllegalStateException(\"Catalog does not support namespaces\");","typeGuard":"boolean supportsNamespaces(Object catalog) {\n  return catalog instanceof org.apache.iceberg.catalog.NamespaceCatalog;\n}","tryCatchPattern":"try {\n  catalog.createNamespace(namespace, metadata);\n} catch (UnsupportedOperationException e) {\n  // catalog lacks namespace support: switch catalog impl or fail setup\n}","preventionTips":["Review the catalog implementation class in spark.sql.catalog.<name> before namespace DDL","Use catalogs known to support namespaces (Hive, JDBC, REST, Nessie, Hadoop)","Document which catalogs in your platform support hierarchical namespaces"],"tags":["spark","namespace","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}