{"record":{"id":"bf67faaaa9ccb50a","repo":"apache/iceberg","slug":"cannot-apply-unknown-namespace-change-change-bf67fa","errorCode":null,"errorMessage":"Cannot apply unknown namespace change: <change>","messagePattern":"Cannot apply unknown namespace change: <change>","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":512,"sourceCode":"      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(\n              \"Cannot apply unknown namespace change: \" + change);\n        }\n      }\n\n      try {\n        if (!updates.isEmpty()) {\n          asNamespaceCatalog.setProperties(Namespace.of(namespace), updates);\n        }\n\n        if (!removals.isEmpty()) {\n          asNamespaceCatalog.removeProperties(Namespace.of(namespace), removals);\n        }\n\n      } catch (org.apache.iceberg.exceptions.NoSuchNamespaceException e) {\n        throw new NoSuchNamespaceException(namespace);\n      }\n    } else {\n      throw new NoSuchNamespaceException(namespace);","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L494-L530","documentation":"Spark's alterNamespace only supports SetProperty and RemoveProperty changes; any other namespace change type passed to SparkCatalog.alterNamespace is rejected with this UnsupportedOperationException. It is a guard against unknown/unimplemented change kinds.","triggerScenarios":"Calling alterNamespace with a change instance that is neither NamespaceChange.SetProperty nor NamespaceChange.RemoveProperty (e.g. a custom or future change type).","commonSituations":"Custom catalog extensions or engine integrations forwarding unsupported namespace mutations (like renames) through the Spark catalog interface.","solutions":["Only build namespace changes via NamespaceChange.setProperty or NamespaceChange.removeProperty","If the change is a rename or other unsupported operation, perform it directly against the underlying Iceberg catalog API instead of via Spark","Update the Iceberg/Spark connector version if a newer change type was intended to be supported"],"exampleFix":"// before\nNamespaceChange change = NamespaceChange.removeProperty(\"owner\"); // wrong type elsewhere\n// after\nsparkCatalog.alterNamespace(ns, NamespaceChange.setProperty(\"owner\", \"team-a\"));","handlingStrategy":"validation","validationCode":"if (!(change instanceof NamespaceChange.SetProperty) && !(change instanceof NamespaceChange.RemoveProperty)) {\n  throw new IllegalArgumentException(\"Unsupported namespace change: \" + change);\n}","typeGuard":"boolean supported(NamespaceChange c) {\n  return c instanceof NamespaceChange.SetProperty || c instanceof NamespaceChange.RemoveProperty;\n}","tryCatchPattern":null,"preventionTips":["Only construct SetProperty/RemoveProperty changes for Spark namespace alters","Handle renames via the native catalog API, not Spark","Check Spark3Util/catalog capabilities before calling alterNamespace"],"tags":["spark","unsupported-operation","namespace"],"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"}