{"record":{"id":"b50529bddc07a55b","repo":"apache/iceberg","slug":"cannot-unset-reserved-property-s","errorCode":null,"errorMessage":"Cannot unset reserved property: '%s'","messagePattern":"Cannot unset reserved property: '(.+?)'","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":727,"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":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L709-L745","documentation":"SparkCatalog.alterView rejects ViewChange.RemoveProperty (and SetProperty) changes whose property name is in SparkView.RESERVED_PROPERTIES (e.g. query, schema, dialect, queryColumnNames managed by Iceberg). verifyNonReservedProperty (SparkCatalog.java:725) throws UnsupportedOperationException with 'Cannot unset reserved property: <name>' because those properties are derived from the view definition and must never be edited directly.","triggerScenarios":"Calling ALTER VIEW <ident> UNSET TBLPROPERTIES ('query') or the programmatic equivalent alterView(ident, new ViewChange.RemoveProperty(\"query\")) — likewise for 'schema', 'dialect', 'description-of-query columns' such as SparkView.QUERY_COLUMN_NAMES — where the property matches a reserved name in SparkView.RESERVED_PROPERTIES.","commonSituations":"Cleanup scripts that iterate all TBLPROPERTIES and UNSET each one, blindly hitting reserved keys; migrating views from Hive where 'query'/'schema' were user-settable; templated UNSET commands with a hardcoded property list that includes reserved names.","solutions":["Remove the reserved key from your UNSET list; reserved properties are managed by the engine and cannot be changed via ALTER VIEW.","To change 'query' or 'schema', redefine the view with CREATE OR REPLACE VIEW instead of altering properties.","Filter properties client-side against SparkView.RESERVED_PROPERTIES before issuing alterView.","Store custom metadata under a non-reserved, prefixed key (e.g. 'custom.owner') and unset that instead."],"exampleFix":"// before\nspark.sql(\"ALTER VIEW analytics.v UNSET TBLPROPERTIES ('query')\"); // UnsupportedOperationException\n\n// after\nspark.sql(\"ALTER VIEW analytics.v UNSET TBLPROPERTIES ('custom.owner')\");\n// redefine reserved metadata instead:\nspark.sql(\"CREATE OR REPLACE VIEW analytics.v AS SELECT ...\");","handlingStrategy":"validation","validationCode":"Set<String> reserved = SparkView.RESERVED_PROPERTIES;\nList<String> safeKeys = propsToUnset.stream()\n    .filter(k -> !reserved.contains(k))\n    .collect(Collectors.toList());\n// only issue UNSET for safeKeys","typeGuard":"boolean isUnsettable(String property) {\n  return !SparkView.RESERVED_PROPERTIES.contains(property);\n}","tryCatchPattern":"try {\n  viewChangeRemover.apply(ident, properties);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Cannot unset reserved property\")) {\n    // skip the reserved key and continue with the remaining properties\n  }\n}","preventionTips":["Filter property lists against SparkView.RESERVED_PROPERTIES before UNSET/SET.","Never blind-UNSET all properties in cleanup scripts; whitelist removable keys.","To change reserved metadata (query/schema/dialect), use CREATE OR REPLACE VIEW instead of ALTER.","Prefix custom metadata keys (e.g. 'custom.') so they can never collide with reserved names."],"tags":["spark","view-catalog","reserved-properties"],"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"}