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 implements ALTER VIEW ... UNSET TBLPROPERTIES for Iceberg views. Unless IF EXISTS is specified, each property key must currently be set on the view; unsetting an absent property throws IcebergAnalysisException naming the offending property.

Solutions

  1. Add IF EXISTS: ALTER VIEW v UNSET TBLPROPERTIES IF EXISTS ('k')
  2. Verify the property is set with SHOW TBLPROPERTIES v before unsetting
  3. Correct the property key spelling/case

Example fix

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

Strategy: validation

Validate before calling

val props = spark.sql(s"SHOW TBLPROPERTIES $viewName").collect().map(_.getString(0)).toSet
val missing = keys.filterNot(props.contains)
require(missing.isEmpty || ifExists, s"Properties not set: ${missing.mkString(",")}")

Try / catch

try { spark.sql(unsetStmt) } catch { case e: IcebergAnalysisException if e.getMessage.contains("Cannot remove property that is not set") => log.warn(s"Skipping unset: ${e.getMessage}") }

Prevention

When it happens

Trigger: Running `ALTER VIEW v UNSET TBLPROPERTIES ('k')` where 'k' is not in the view's properties and the statement lacks IF EXISTS; also any of several listed keys missing causes the first missing key to fail.

Common situations: Removing a property that was never set or was already removed (idempotent-cleanup scripts), typos in property names, or case-sensitivity mismatches in keys.

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/c996e5e042e081a2. Report an issue: GitHub.

Appendix: source

Thrown at spark/v4.0/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)