{"record":{"id":"2e3b4b32bad9f4a9","repo":"apache/iceberg","slug":"nosuchtableexception-ident","errorCode":null,"errorMessage":"NoSuchTableException(ident)","messagePattern":"NoSuchTableException\\(ident\\)","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":367,"sourceCode":"        } else {\n          propertyChanges.add(set);\n        }\n      } else if (change instanceof RemoveProperty) {\n        propertyChanges.add(change);\n      } else if (change instanceof ColumnChange) {\n        schemaChanges.add(change);\n      } else {\n        throw new UnsupportedOperationException(\"Cannot apply unknown table change: \" + change);\n      }\n    }\n\n    try {\n      org.apache.iceberg.Table table = icebergCatalog.loadTable(buildIdentifier(ident));\n      commitChanges(\n          table, setLocation, setSnapshotId, pickSnapshotId, propertyChanges, schemaChanges);\n      return new SparkTable(table, true /* refreshEagerly */);\n    } catch (org.apache.iceberg.exceptions.NoSuchTableException e) {\n      throw new NoSuchTableException(ident);\n    }\n  }\n\n  @Override\n  public boolean dropTable(Identifier ident) {\n    return catalogDropTable(ident);\n  }\n\n  @Override\n  public boolean purgeTable(Identifier ident) {\n    try {\n      org.apache.iceberg.Table table = icebergCatalog.loadTable(buildIdentifier(ident));\n      ValidationException.check(\n          PropertyUtil.propertyAsBoolean(table.properties(), GC_ENABLED, GC_ENABLED_DEFAULT),\n          \"Cannot purge table: GC is disabled (deleting files may corrupt other tables)\");\n      String metadataFileLocation =\n          ((HasTableOperations) table).operations().current().metadataFileLocation();\n","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L349-L385","documentation":"Spark's alterTable was called with an identifier, but the underlying Iceberg catalog could not load a table with that name, so org.apache.iceberg.exceptions.NoSuchTableException was caught and rethrown as Spark's NoSuchTableException. This means the table does not exist (or is not visible) in the configured catalog. Spark rethrows it so callers see the catalog plugin's checked exception type.","triggerScenarios":"Calling ALTER TABLE on a table resolved through an Iceberg Spark catalog whose loadTable(ident) fails; the table was dropped by another process between resolution and ALTER; wrong catalog/namespace qualifier in the identifier; or a case-sensitivity mismatch between Spark's identifier and the Iceberg catalog's stored name.","commonSituations":"Running ALTER TABLE ... SET TBLPROPERTIES against a table created under a different catalog (e.g. spark_catalog vs a custom HadoopCatalog); typos in three-part table names; HDFS/S3 outages making manifest lookups fail and surface as NoSuchTable; multi-tenant setups where another job dropped the table mid-flight.","solutions":["Verify the exact table exists with SELECT or SHOW TABLES IN <catalog>.<namespace> using the same catalog and namespace as the ALTER statement.","Check the fully-qualified identifier: ensure session catalog (spark_catalog) vs named Iceberg catalog configuration matches how the table was created.","Confirm no concurrent job dropped the table; inspect catalog/Hive metastore contents directly.","If the table exists but loadTable fails, check the catalog's warehouse/FileIO configuration (permissions, endpoint) in the Spark conf."],"exampleFix":"// before\nspark.sql(\"ALTER TABLE mydb.orders SET TBLPROPERTIES ('note'='x')\") // NoSuchTableException\n\n// after\nif (!spark.catalog().tableExists(\"iceberg_catalog.mydb.orders\")) {\n  throw new IllegalStateException(\"Table missing - check catalog name\");\n}\nspark.sql(\"ALTER TABLE iceberg_catalog.mydb.orders SET TBLPROPERTIES ('note'='x')\")","handlingStrategy":"try-catch","validationCode":"if (!spark.catalog().tableExists(\"iceberg_catalog.mydb.orders\")) {\n  throw new IllegalStateException(\"Table does not exist before ALTER\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  spark.sql(\"ALTER TABLE iceberg_catalog.mydb.orders SET TBLPROPERTIES (...)\");\n} catch (NoSuchTableException e) {\n  // table absent or unloaded: log identifier from e, create or re-register it\n}","preventionTips":["Always use fully-qualified catalog.namespace.table identifiers","Check tableExists before DDL in scripts","Keep catalog conf consistent between creation and alteration sessions","Coordinate drops across concurrent jobs"],"tags":["spark","catalog","table-not-found"],"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-14T16:17:12.679Z"}