{"record":{"id":"90a2c40fbb3177fb","repo":"apache/iceberg","slug":"failed-to-load-catalog-90a2c4","errorCode":null,"errorMessage":"Failed to load catalog: {}","messagePattern":"Failed to load catalog: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java","lineNumber":864,"sourceCode":"  public static CatalogAndIdentifier catalogAndIdentifier(\n      SparkSession spark, List<String> nameParts, CatalogPlugin defaultCatalog) {\n    CatalogManager catalogManager = spark.sessionState().catalogManager();\n\n    String[] currentNamespace;\n    if (defaultCatalog.equals(catalogManager.currentCatalog())) {\n      currentNamespace = catalogManager.currentNamespace();\n    } else {\n      currentNamespace = defaultCatalog.defaultNamespace();\n    }\n\n    Pair<CatalogPlugin, Identifier> catalogIdentifier =\n        SparkUtil.catalogAndIdentifier(\n            nameParts,\n            catalogName -> {\n              try {\n                return catalogManager.catalog(catalogName);\n              } catch (Exception e) {\n                LOG.warn(\"Failed to load catalog: {}\", catalogName, e);\n                return null;\n              }\n            },\n            Identifier::of,\n            defaultCatalog,\n            currentNamespace);\n    return new CatalogAndIdentifier(catalogIdentifier);\n  }\n\n  private static TableCatalog asTableCatalog(CatalogPlugin catalog) {\n    if (catalog instanceof TableCatalog) {\n      return (TableCatalog) catalog;\n    }\n\n    throw new IllegalArgumentException(\n        String.format(\n            \"Cannot use catalog %s(%s): not a TableCatalog\",\n            catalog.name(), catalog.getClass().getName()));","sourceCodeStart":846,"sourceCodeEnd":882,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java#L846-L882","documentation":"When resolving a table/part identifier, Spark3Util asks the Spark CatalogManager to load each candidate catalog by name. If catalog loading throws, the exception is logged as a warning and null is returned so identifier resolution can continue with the next candidate or the default catalog. This means the named catalog is unusable, not necessarily that the table lookup failed.","triggerScenarios":"catalogManager.catalog(name) throws during catalogAndIdentifier resolution — e.g. the catalog plugin class cannot be instantiated, its options are wrong, or the underlying metastore is unreachable.","commonSituations":"Typos in catalog name in USE/queries; misconfigured catalog options in Spark conf (missing warehouse/metadata URLs); metastore (Hive/REST/Nessie) downtime.","solutions":["Check the chained exception in the log — fix the catalog config (e.g. uri, warehouse, credential options)","Verify the catalog name spelling and that it is registered in Spark session catalog confs","Test catalog availability directly (e.g. SHOW CATALOGS / listing via the catalog client) to isolate connectivity issues"],"exampleFix":"// before\nspark.sql.catalog.my_cat.type=rest\nspark.sql.catalog.my_cat.uri=https://wrong-host:8181\n// after\nspark.sql.catalog.my_cat.type=rest\nspark.sql.catalog.my_cat.uri=http://catalog-host:8181","handlingStrategy":"try-catch","validationCode":"try {\n  Catalog c = spark.sessionState().catalogManager().catalog(name);\n} catch (Exception e) {\n  // catalog misconfigured; fix conf before resolving identifiers\n}","typeGuard":null,"tryCatchPattern":"try {\n  spark.table(\"my_cat.db.tbl\");\n} catch (Exception e) {\n  LOG.warn(\"Catalog load failed\", e);\n  // check conf: spark.sql.catalog.my_cat.*\n}","preventionTips":["Validate catalog configs at session startup (USE catalog)","Keep catalog endpoint configs in a checked-in Spark conf template","Alert on metastore/REST catalog health"],"tags":["spark","catalog","configuration","resolution"],"backgroundTag":"resource-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"}