{"record":{"id":"9325a03012ac8c1c","repo":"apache/iceberg","slug":"cannot-apply-unknown-namespace-change-change","errorCode":null,"errorMessage":"Cannot apply unknown namespace change: ${change}","messagePattern":"Cannot apply unknown namespace change: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":540,"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":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L522-L558","documentation":"alterNamespace was given a NamespaceChange type other than SetProperty or RemoveProperty (e.g. a future/unknown change kind), and the switch-style dispatch could not handle it, so UnsupportedOperationException('Cannot apply unknown namespace change: <change>') is thrown. Iceberg's namespace alteration supports only property set/remove operations.","triggerScenarios":"Calling catalog.alterNamespace(ns, change) with a custom or new NamespaceChange subclass; framework-generated changes from newer Spark/Iceberg versions not anticipated by this handler; code constructing NamespaceChange directly with an unexpected variant.","commonSituations":"Version drift where Spark emits a change type the pinned Iceberg handler does not know; custom metadata layers building generic change pipelines that pass through unsupported change kinds; hand-written catalog abstraction layers.","solutions":["Only issue NamespaceChange.setProperty/removeProperty changes; translate other intents accordingly.","Align Spark and Iceberg-Spark module versions so change types match what this handler supports.","Filter/validate the change list before calling alterNamespace, rejecting unknown kinds up front.","If a new change kind is genuinely needed, extend the handler and file an Iceberg issue instead of passing it through."],"exampleFix":"// before\ncatalog.alterNamespace(ns, someCustomChange); // UnsupportedOperationException\n\n// after\nif (change instanceof NamespaceChange.SetProperty || change instanceof NamespaceChange.RemoveProperty) {\n  catalog.alterNamespace(ns, change);\n} else {\n  throw new IllegalArgumentException(\"Unsupported change kind: \" + change.getClass().getName());\n}","handlingStrategy":"validation","validationCode":"for (NamespaceChange change : changes) {\n  if (!(change instanceof NamespaceChange.SetProperty)\n      && !(change instanceof NamespaceChange.RemoveProperty)) {\n    throw new IllegalArgumentException(\"Unsupported change: \" + change);\n  }\n}","typeGuard":"boolean isSupportedNamespaceChange(NamespaceChange change) {\n  return change instanceof NamespaceChange.SetProperty\n      || change instanceof NamespaceChange.RemoveProperty;\n}","tryCatchPattern":"try {\n  catalog.alterNamespace(ns, changes);\n} catch (UnsupportedOperationException e) {\n  // unknown change kind: pin matching Spark/Iceberg versions and translate the change\n}","preventionTips":["Only issue SetProperty/RemoveProperty namespace changes","Keep Spark and iceberg-spark module versions aligned","Validate change lists before alterNamespace","Handle future change kinds explicitly in generic change pipelines"],"tags":["spark","catalog","namespace","unsupported-change-type"],"backgroundTag":"unsupported-enum-value","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"}