apache/iceberg · error

Cannot remove property that is not set: '$property'

Error message

Cannot remove property that is not set: '$property'

What it means

ALTER VIEW ... UNSET PROPERTIES without IF EXISTS fails if any listed property key is not currently set on the view. The exec scans the view's properties and throws an AnalysisException naming the first missing key; with IF EXISTS the missing keys are silently skipped.

Solutions

  1. Add IF EXISTS: ALTER VIEW v UNSET TBLPROPERTIES IF EXISTS ('k')
  2. Check current properties first (e.g. DESCRIBE VIEW EXTENDED or catalog API) and only unset keys that are present
  3. Correct the property key spelling

Example fix

// before
ALTER VIEW catalog.db.v UNSET TBLPROPERTIES ('comment');
// after
ALTER VIEW catalog.db.v UNSET TBLPROPERTIES IF EXISTS ('comment');
Defensive patterns

Strategy: try-catch

Validate before calling

val view = catalog.loadView(ident)
val missing = propertyKeys.filterNot(key => view.properties.containsKey(key))
require(missing.isEmpty || ifExists, s"Properties not set: $missing")

Try / catch

try { spark.sql(unsetDdl) } catch { case e: AnalysisException if e.getMessage.contains("Cannot remove property that is not set") => log.warn("property already unset; use IF EXISTS") }

Prevention

When it happens

Trigger: Running ALTER VIEW v UNSET TBLPROPERTIES ('k') where 'k' is absent from the view's properties and the statement lacks IF EXISTS.

Common situations: Idempotent cleanup scripts re-unsetting already-removed properties; typo'd property keys; concurrent removal by another job.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/e4df05ee25ec4e28. Report an issue: GitHub.

Appendix: source

Thrown at spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/AlterV2ViewUnsetPropertiesExec.scala:40

import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.Attribute
import org.apache.spark.sql.connector.catalog.Identifier
import org.apache.spark.sql.connector.catalog.ViewCatalog
import org.apache.spark.sql.connector.catalog.ViewChange

case class AlterV2ViewUnsetPropertiesExec(
    catalog: ViewCatalog,
    ident: Identifier,
    propertyKeys: Seq[String],
    ifExists: Boolean)
    extends LeafV2CommandExec {

  override lazy val output: Seq[Attribute] = Nil

  override protected def run(): Seq[InternalRow] = {
    if (!ifExists) {
      propertyKeys.filterNot(catalog.loadView(ident).properties.containsKey).foreach { property =>
        throw new AnalysisException(s"Cannot remove property that is not set: '$property'")
      }
    }

    val changes = propertyKeys.map(ViewChange.removeProperty)
    catalog.alterView(ident, changes: _*)

    Nil
  }

  override def simpleString(maxFields: Int): String = {
    s"AlterV2ViewUnsetProperties: ${ident}"
  }
}

View on GitHub (pinned to 86d9c8fc54)