{"record":{"id":"ec57205a3fb62699","repo":"apache/iceberg","slug":"cannot-load-underlying-iceberg-view-for-view-ide","errorCode":null,"errorMessage":"Cannot load underlying Iceberg view for view: $ident","messagePattern":"Cannot load underlying Iceberg view for view: \\$ident","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/IcebergAlterV2ViewSetPropertiesExec.scala","lineNumber":51,"sourceCode":" * Uses a custom command instead of Spark's built-in implementation so Iceberg catalogs commit\n * property-only metadata updates and reject changes to reserved view properties.\n */\ncase class IcebergAlterV2ViewSetPropertiesExec(\n    catalog: ViewCatalog,\n    ident: Identifier,\n    properties: Map[String, String])\n    extends LeafV2CommandExec {\n\n  override lazy val output: Seq[Attribute] = Nil\n\n  override protected def run(): Seq[InternalRow] = {\n    properties.keys.foreach(verifyNonReservedPropertyIsSet)\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    properties.foreach { case (key, value) => update.set(key, value) }\n    CommandUtils.uncacheTableOrView(session, ResolvedIdentifier(catalog, ident))\n    update.commit()\n\n    Nil\n  }\n\n  override def simpleString(maxFields: Int): String = {\n    s\"IcebergAlterV2ViewSetProperties: ${ident}\"\n  }\n\n  private def verifyNonReservedPropertyIsSet(property: String): Unit = {\n    if (SparkView.isReservedProperty(property)) {\n      throw new UnsupportedOperationException(s\"Cannot set reserved property: '$property'\")\n    }\n  }\n}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/IcebergAlterV2ViewSetPropertiesExec.scala#L33-L69","documentation":"This IllegalStateException is thrown by IcebergAlterV2ViewSetPropertiesExec when ViewUtil.loadIcebergView returns empty, i.e. the resolved view identifier exists to Spark but no underlying Iceberg view could be loaded from the catalog. Only views actually backed by Iceberg support ALTER VIEW ... SET PROPERTIES via this path.","triggerScenarios":"Running 'ALTER VIEW ... SET PROPERTIES/SET TBLPROPERTIES' on a view registered in a ViewCatalog but whose underlying view is not an Iceberg view (loadIcebergView returns None).","commonSituations":"The view was created by another engine/provider and only registered in Spark; the catalog metadata changed or the view was replaced between resolution and execution; pointing ALTER VIEW at a temp or non-Iceberg view.","solutions":["Confirm the view was created as an Iceberg view (via Iceberg catalog DDL)","Recreate the view under the Iceberg catalog, then set properties","Check that the view still exists and the identifier matches (no replacement by a non-Iceberg view)","Inspect ViewUtil.loadIcebergView behavior to ensure the catalog supports loading Iceberg views"],"exampleFix":"// before: view not backed by Iceberg\nALTER VIEW spark_catalog.db.v SET TBLPROPERTIES ('key'='val');\n// after\nALTER VIEW iceberg_catalog.db.v SET TBLPROPERTIES ('key'='val');","handlingStrategy":"try-catch","validationCode":"import org.apache.iceberg.spark.view.ViewUtil\nViewUtil.loadIcebergView(catalog, ident) match {\n  case Some(_) => // safe to alter properties\n  case None    => sys.error(s\"$ident is not an Iceberg view\")\n}","typeGuard":"def isIcebergView(catalog: ViewCatalog, ident: Identifier): Boolean =\n  ViewUtil.loadIcebergView(catalog, ident).isDefined","tryCatchPattern":"try { spark.sql(\"ALTER VIEW ... SET TBLPROPERTIES (...)\") } catch {\n  case e: IllegalStateException if e.getMessage.contains(\"Cannot load underlying Iceberg view\") =>\n    logError(\"view is not backed by Iceberg; recreate under the Iceberg catalog\", e)\n}","preventionTips":["Create views through the Iceberg catalog so they are Iceberg-backed","Re-check the view after any catalog migration or replacement","Verify catalog type supports Iceberg views before ALTER VIEW property DDL"],"tags":["spark","iceberg","view","properties"],"backgroundTag":"entity-not-found","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"}