apache/iceberg · error · NoSuchViewException

View not found: ${ident.quoted}

Error message

View not found: ${ident.quoted}

What it means

This NoSuchViewException (message 'View not found: <ident>') is thrown by DropV2ViewExec when the view catalog's dropView(ident) returns false and IF EXISTS was not specified. It means the DROP VIEW targeted a view identifier that does not exist in the given V2/ViewCatalog.

Source

Thrown at spark/v4.2/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DropV2ViewExec.scala:35

 * under the License.
 */
package org.apache.spark.sql.execution.datasources.v2

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

case class DropV2ViewExec(catalog: ViewCatalog, ident: Identifier, ifExists: Boolean)
    extends LeafV2CommandExec {

  override lazy val output: Seq[Attribute] = Nil

  override protected def run(): Seq[InternalRow] = {
    val dropped = catalog.dropView(ident)
    if (!dropped && !ifExists) {
      throw new NoSuchViewException(ident)
    }

    Nil
  }

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

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. List existing views (SHOW VIEWS / catalog API) to confirm the exact identifier
  2. Add IF EXISTS: DROP VIEW IF EXISTS catalog.db.name
  3. Check the catalog qualification matches where the view was created
  4. Verify you are connected to the right catalog/environment

Example fix

// before: fails if view missing
DROP VIEW iceberg_catalog.db.old_view;
// after
DROP VIEW IF EXISTS iceberg_catalog.db.old_view;
Defensive patterns

Strategy: try-catch

Validate before calling

import org.apache.spark.sql.catalyst.analysis.NoSuchViewException
val exists = scala.util.Try(spark.sessionState.catalog.tableExists(ident)).getOrElse(false)
if (!exists && !ifExists) sys.error(s"View ${ident.quoted} does not exist")

Try / catch

try { spark.sql("DROP VIEW iceberg_catalog.db.v") } catch {
  case e: org.apache.spark.sql.catalyst.analysis.NoSuchViewException =>
    logWarning(s"view already gone: ${e.getMessage}")
}

Prevention

When it happens

Trigger: Running 'DROP VIEW catalog.db.name' (routed through Iceberg's extended strategy) where no view with that identifier exists in the catalog, and IF EXISTS is absent.

Common situations: Typo in the view name or namespace; the view was already dropped; the view exists in a different catalog than the one qualified; case-sensitivity differences between sessions.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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