{"record":{"id":"b904760bf2ebd970","repo":"apache/iceberg","slug":"cannot-load-underlying-iceberg-view-for-view-ide-b90476","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/IcebergAlterV2ViewUnsetPropertiesExec.scala","lineNumber":63,"sourceCode":"  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}\"\n  }\n\n  private def verifyNonReservedPropertyIsUnset(property: String): Unit = {\n    if (SparkView.isReservedProperty(property)) {\n      throw new UnsupportedOperationException(s\"Cannot unset reserved property: '$property'\")\n    }\n  }\n}","sourceCodeStart":45,"sourceCodeEnd":81,"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#L45-L81","documentation":"After loading the view metadata through the catalog, the executor must obtain the underlying Iceberg `View` object via `ViewUtil.loadIcebergView`. If that returns empty, the view metadata exists in the catalog but no underlying Iceberg view implementation can be resolved, so an IllegalStateException is thrown rather than committing against a wrong object.","triggerScenarios":"Executing `IcebergAlterV2ViewUnsetPropertiesExec` (i.e. `ALTER VIEW ... UNSET TBLPROPERTIES`) when `ViewUtil.loadIcebergView(catalog, ident)` returns `None` — e.g. the catalog entry is not backed by an Iceberg view or cannot be loaded.","commonSituations":"Pointing the SQL at a non-Iceberg view in a hybrid catalog; catalog/plugin misconfiguration so the view isn't registered as an Iceberg view; stale metadata after concurrent drop/recreate.","solutions":["Confirm the view is actually an Iceberg view (created via the Iceberg catalog)","Check catalog configuration so view metadata is registered correctly","Re-create the view if metadata is stale or corrupted","Check that the correct catalog is named in the identifier"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify the view resolves through the Iceberg catalog\nval catalog = Spark3Util.loadIcebergCatalog(spark, catalogName)\nrequire(catalog.asViewCatalog != null && catalog.loadView(ident) != null, \"not an Iceberg view\")","typeGuard":null,"tryCatchPattern":"try { spark.sql(alterSql) } catch { case e: IllegalStateException if e.getMessage.contains(\"Cannot load underlying Iceberg view\") => /* view is not Iceberg-backed; handle */ }","preventionTips":["Confirm views are created through the Iceberg catalog","Qualify identifiers with the Iceberg catalog name","Avoid concurrent drop/recreate while altering views"],"tags":["spark","sql","view","illegal-state"],"backgroundTag":"internal-invariant-violation","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"}