{"record":{"id":"372f2947aacd330d","repo":"apache/iceberg","slug":"cannot-remove-property-that-is-not-set-property-372f29","errorCode":null,"errorMessage":"Cannot remove property that is not set: '$property'","messagePattern":"Cannot remove property that is not set: '\\$property'","errorType":"exception","errorClass":"IcebergAnalysisException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/IcebergAlterV2ViewUnsetPropertiesExec.scala","lineNumber":55,"sourceCode":" */\ncase class IcebergAlterV2ViewUnsetPropertiesExec(\n    catalog: ViewCatalog,\n    ident: Identifier,\n    propertyKeys: Seq[String],\n    ifExists: Boolean)\n    extends LeafV2CommandExec {\n\n  override lazy val output: Seq[Attribute] = Nil\n\n  override protected def run(): Seq[InternalRow] = {\n    propertyKeys.foreach(verifyNonReservedPropertyIsUnset)\n\n    val viewInfo = catalog.loadView(ident)\n    val properties = viewInfo.properties.asScala.toMap\n\n    if (!ifExists) {\n      propertyKeys.filterNot(properties.contains).foreach { property =>\n        throw new IcebergAnalysisException(s\"Cannot remove property that is not set: '$property'\")\n      }\n    }\n\n    val view =\n      ViewUtil\n        .loadIcebergView(catalog, ident)\n        .getOrElse(\n          throw new IllegalStateException(s\"Cannot load underlying Iceberg view for view: $ident\"))\n    val update = view.updateProperties()\n    propertyKeys.foreach(update.remove)\n    CommandUtils.uncacheTableOrView(session, ResolvedIdentifier(catalog, ident))\n    update.commit()\n\n    Nil\n  }\n\n  override def simpleString(maxFields: Int): String = {\n    s\"IcebergAlterV2ViewUnsetProperties: ${ident}\"","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/IcebergAlterV2ViewUnsetPropertiesExec.scala#L37-L73","documentation":"This error is thrown when an `ALTER VIEW ... UNSET TBLPROPERTIES` command targets a property key that is not currently set on the Iceberg view. The executor loads the view's properties and, unless `IF EXISTS` was specified, fails fast when any requested key is absent, instead of silently doing nothing.","triggerScenarios":"Running `ALTER VIEW ident UNSET TBLPROPERTIES ('key')` where 'key' is not among `viewInfo.properties`, and `ifExists` is false.","commonSituations":"Typo in the property name; property was already unset in a previous run (non-idempotent scripts); key set only at table/catalog level, not view level.","solutions":["Verify the property exists first with `DESCRIBE VIEW EXTENDED` or `SHOW TBLPROPERTIES`","Add `IF EXISTS` to the statement so missing properties are skipped","Fix the property key spelling","Make scripts idempotent by checking properties before unsetting"],"exampleFix":"// before\nALTER VIEW myview UNSET TBLPROPERTIES ('comment.legacy')\n// after\nALTER VIEW myview UNSET TBLPROPERTIES IF EXISTS ('comment.legacy')","handlingStrategy":"validation","validationCode":"val props = spark.sql(s\"SHOW TBLPROPERTIES $viewName\").collect().map(_.getString(0)).toSet\nrequire(props.forall(props.contains), s\"Properties not set: ${props.mkString(\",\")}\")","typeGuard":null,"tryCatchPattern":"try { spark.sql(unsetSql) } catch { case e: IcebergAnalysisException if e.getMessage.contains(\"Cannot remove property that is not set\") => /* skip or log */ }","preventionTips":["List current properties with SHOW TBLPROPERTIES before unsetting","Use IF EXISTS in all scripted UNSET statements","Centralize property key names as constants to avoid typos"],"tags":["spark","sql","view-properties","validation"],"backgroundTag":"missing-required-argument","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"}