{"record":{"id":"806a9d39b01793db","repo":"apache/iceberg","slug":"cannot-unset-reserved-property-s-cannot-set","errorCode":null,"errorMessage":"Cannot unset reserved property: '%s' / Cannot set reserved property: '%s' (via errorMsg template)","messagePattern":"Cannot unset reserved property: '(.+?)' / Cannot set reserved property: '(.+?)' \\(via errorMsg template\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":726,"sourceCode":"            updateViewProperties.remove(remove.property());\n          }\n        }\n\n        updateViewProperties.commit();\n\n        return new SparkView(catalogName, view);\n      } catch (org.apache.iceberg.exceptions.NoSuchViewException e) {\n        throw new NoSuchViewException(ident);\n      }\n    }\n\n    throw new UnsupportedOperationException(\n        \"Altering a view is not supported by catalog: \" + catalogName);\n  }\n\n  private static void verifyNonReservedProperty(String property, String errorMsg) {\n    if (SparkView.RESERVED_PROPERTIES.contains(property)) {\n      throw new UnsupportedOperationException(String.format(errorMsg, property));\n    }\n  }\n\n  private static void verifyNonReservedPropertyIsUnset(String property) {\n    verifyNonReservedProperty(property, \"Cannot unset reserved property: '%s'\");\n  }\n\n  private static void verifyNonReservedPropertyIsSet(String property) {\n    verifyNonReservedProperty(property, \"Cannot set reserved property: '%s'\");\n  }\n\n  @Override\n  public boolean dropView(Identifier ident) {\n    if (null != asViewCatalog) {\n      return asViewCatalog.dropView(buildIdentifier(ident));\n    }\n\n    return false;","sourceCodeStart":708,"sourceCodeEnd":744,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L708-L744","documentation":"verifyNonReservedProperty throws UnsupportedOperationException with either 'Cannot set reserved property: <name>' or 'Cannot unset reserved property: <name>' when a view property change targets a property reserved by SparkView (e.g. 'view-provider', 'identifier', 'location'). Reserved properties control engine behavior and cannot be modified through SET/UNSET TBLPROPERTIES on views.","triggerScenarios":"ALTER VIEW ... SET TBLPROPERTIES ('provider'='...') or UNSET TBLPROPERTIES on any property in SparkView.RESERVED_PROPERTIES, applied via alterView through SparkCatalog.","commonSituations":"Users copying table DDL habits (like setting 'provider') to views; migration scripts that unset engine-managed properties; attempting to change view metadata that Iceberg manages internally.","solutions":["Remove the reserved property key from the SET/UNSET TBLPROPERTIES clause.","Recreate the view with the desired definition/properties if engine metadata must change.","Set only user-level properties not listed in SparkView.RESERVED_PROPERTIES."],"exampleFix":"// before\nspark.sql(\"ALTER VIEW v UNSET TBLPROPERTIES ('provider')\") // throws\n// after\nspark.sql(\"ALTER VIEW v UNSET TBLPROPERTIES ('my.custom.prop')\")","handlingStrategy":"validation","validationCode":"import static org.apache.iceberg.spark.SparkView.RESERVED_PROPERTIES;\nif (RESERVED_PROPERTIES.contains(propName)) {\n  throw new IllegalArgumentException(\"Property is reserved and cannot be changed: \" + propName);\n}","typeGuard":null,"tryCatchPattern":"try {\n  sparkCatalog.alterView(ident, setProperty(k, v));\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"reserved property\")) { /* choose a non-reserved key */ }\n  throw e;\n}","preventionTips":["Consult SparkView.RESERVED_PROPERTIES before building property updates.","Namespace custom view properties (e.g. 'myapp.prop').","Never SET/UNSET engine-managed keys like provider or identifier."],"tags":["spark","view","reserved-properties","unsupported-operation"],"backgroundTag":"invalid-argument-value","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"}