apache/iceberg · error · IcebergAnalysisException

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

Error message

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

What it means

AlterV2ViewUnsetPropertiesExec validates that every property key being unset actually exists in the view's properties, unless IF EXISTS was specified. If a key is missing and ifExists is false, it throws this IcebergAnalysisException before building the ViewChange to protect against silently dropping a typo'd key.

Solutions

  1. Add IF EXISTS to tolerate missing keys: `ALTER VIEW v UNSET TBLPROPERTIES IF EXISTS ('key')`.
  2. Verify the exact property key via `DESCRIBE VIEW EXTENDED` or the catalog's view properties.
  3. Skip properties already removed in your script.
  4. Check key casing/spelling against what was originally set.

Example fix

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

Strategy: validation

Validate before calling

// Scala: check the property exists before unsetting
val props = catalog.loadView(ident).properties
val missing = propertyKeys.filterNot(props.containsKey)
if (missing.nonEmpty) propertyKeys = propertyKeys.filter(props.containsKey) // or use IF EXISTS in SQL

Try / catch

// Scala
try { spark.sql(alterViewStmt) } catch {
  case e: AnalysisException if e.getMessage.contains("Cannot remove property that is not set") =>
    // retry with IF EXISTS or ignore
}

Prevention

When it happens

Trigger: Running `ALTER VIEW ... UNSET TBLPROPERTIES ('key')` where 'key' is not currently set on the view and the statement lacks IF EXISTS.

Common situations: Unsetting a property with a typo in the key name, double-unsetting the same property in a session, cleaning up properties that were already removed, or key-casing differences.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

import org.apache.spark.sql.catalyst.analysis.IcebergAnalysisException
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 IcebergAnalysisException(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)