{"record":{"id":"d09fda7c20489d89","repo":"apache/iceberg","slug":"couldn-t-load-table-s-in-catalog-s-d09fda","errorCode":null,"errorMessage":"Couldn't load table '%s' in catalog '%s'","messagePattern":"Couldn't load table '(.+?)' in catalog '(.+?)'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/procedures/BaseProcedure.java","lineNumber":175,"sourceCode":"    Preconditions.checkArgument(\n        identifierAsString != null && !identifierAsString.isEmpty(),\n        \"Cannot handle an empty identifier for argument %s\",\n        argName);\n\n    return Spark3Util.catalogAndIdentifier(\n        \"identifier for arg \" + argName, spark, identifierAsString, catalog);\n  }\n\n  protected SparkTable loadSparkTable(Identifier ident) {\n    try {\n      Table table = tableCatalog.loadTable(ident);\n      ValidationException.check(\n          table instanceof SparkTable, \"%s is not %s\", ident, SparkTable.class.getName());\n      return (SparkTable) table;\n    } catch (NoSuchTableException e) {\n      String errMsg =\n          String.format(\"Couldn't load table '%s' in catalog '%s'\", ident, tableCatalog.name());\n      throw new RuntimeException(errMsg, e);\n    }\n  }\n\n  protected Dataset<Row> loadRows(Identifier tableIdent, Map<String, String> options) {\n    String tableName = Spark3Util.quotedFullIdentifier(tableCatalog().name(), tableIdent);\n    return spark().read().options(options).table(tableName);\n  }\n\n  protected void refreshSparkCache(Identifier ident, Table table) {\n    CacheManager cacheManager = spark.sharedState().cacheManager();\n    DataSourceV2Relation relation =\n        DataSourceV2Relation.create(table, Option.apply(tableCatalog), Option.apply(ident));\n    cacheManager.recacheByPlan(spark, relation);\n  }\n\n  protected Expression filterExpression(Identifier ident, String where) {\n    try {\n      String name = Spark3Util.quotedFullIdentifier(tableCatalog.name(), ident);","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/procedures/BaseProcedure.java#L157-L193","documentation":"BaseProcedure.loadSparkTable resolves a table identifier through the given Spark catalog and casts it to SparkTable. When the catalog throws NoSuchTableException, the procedure wraps it in a RuntimeException reporting the table identifier and catalog name, because the procedure cannot proceed without the target table.","triggerScenarios":"Calling a procedure (e.g. rewrite_data_files, expire_snapshots, remove_orphan_files) with a TABLE identifier that does not exist, is misspelled, or lives in a different catalog/namespace than specified.","commonSituations":"Typos in table names; forgetting the catalog prefix when multiple catalogs are configured (spark.sql.catalog.*); table dropped concurrently; wrong namespace; case-sensitivity issues in identifiers.","solutions":["Verify the table exists: SHOW TABLES IN <catalog>.<namespace> and check the exact name","Use the fully qualified identifier including catalog: catalog.namespace.table","Check spark.sql.defaultCatalog / USE statements so the unqualified name resolves to the right catalog","Catch the RuntimeException around CALL if you need to handle missing tables gracefully"],"exampleFix":"// before\nCALL catalog.system.rewrite_data_files(table => 'db.tbl'); -- tbl missing\n// after\n-- verify first: SHOW TABLES IN catalog.db;\nCALL catalog.system.rewrite_data_files(table => 'catalog.db.tbl');","handlingStrategy":"try-catch","validationCode":"// verify existence before the CALL\nspark.sql(s\"SHOW TABLES IN $catalog.$namespace\").filter(col(\"name\") === tableName)","typeGuard":null,"tryCatchPattern":"try { spark.sql(procedureCall) } catch { case e: RuntimeException if e.getMessage.startsWith(\"Couldn't load table\") => /* handle missing table */ }","preventionTips":["Use fully qualified catalog.namespace.table identifiers","Run SHOW TABLES / DESCRIBE TABLE before procedures","Set the correct default catalog (USE catalog) in the session"],"tags":["spark","procedures","table-not-found","catalog"],"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"}