{"record":{"id":"b20fe9593dd1055d","repo":"apache/iceberg","slug":"failed-to-load-catalog-b20fe9","errorCode":null,"errorMessage":"Failed to load catalog: {}","messagePattern":"Failed to load catalog: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java","lineNumber":847,"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":829,"sourceCodeEnd":865,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java#L829-L865","documentation":"A logged warning raised inside the catalogName resolver lambda passed to SparkUtil.catalogAndIdentifier when catalogManager.catalog(name) throws. Instead of failing identifier resolution outright, the resolver returns null so the next catalog/name-part interpretation is tried. It means one candidate catalog name could not be loaded (missing catalog config, bad class, init failure), and resolution falls through.","triggerScenarios":"Resolving a table/namespace identifier whose first name part is treated as a catalog name but CatalogManager fails to load it — e.g., 'spark.catalog.mynewcatalog' never configured, catalog implementation class missing from the classpath, or catalog init throwing.","commonSituations":"Typos in catalog names in SQL ('iceberg_tbl' vs catalog 'iceberg'); catalogs referenced in multi-part identifiers that were never configured in spark.sql.catalog.*; catalog plugin classes not shipped on the classpath; Hadoop/Hive metastore connection failures during catalog init.","solutions":["Verify the catalog is configured: spark.sql.catalog.<name>=org.apache.iceberg.spark.SparkCatalog plus its type/uri options.","Fix the catalog name typo in the identifier or SQL statement.","Add the catalog implementation jar to the Spark classpath if the implementation class is missing.","Check the chained exception for the root cause (metastore connection, bad URI, invalid options).","Fully qualify identifiers with a configured catalog name so resolution does not guess name parts."],"exampleFix":"// before\nSELECT * FROM prod.db.tbl;  // 'prod' not configured\n// after\nspark.conf.set(\"spark.sql.catalog.prod\", \"org.apache.iceberg.spark.SparkCatalog\");\nspark.conf.set(\"spark.sql.catalog.prod.type\", \"hadoop\");\nSELECT * FROM prod.db.tbl;","handlingStrategy":"validation","validationCode":"// confirm the catalog is configured before referencing it\nif (spark.conf().get(\"spark.sql.catalog.prod\", null) == null) {\n  throw new IllegalArgumentException(\"Catalog 'prod' is not configured\");\n}","typeGuard":null,"tryCatchPattern":"// wrap identifier resolution and fall back to an explicit catalog reference\ntry { spark.table(\"prod.db.tbl\"); } catch (Exception e) { spark.table(\"default.db.tbl\"); }","preventionTips":["Configure every catalog you reference via spark.sql.catalog.<name>.*","Fully qualify table identifiers with a configured catalog name","Ship catalog implementation jars on the Spark classpath","Test catalog connectivity at job startup, not lazily"],"tags":["spark","catalog","identifier-resolution","configuration"],"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-23T08:17:48.524Z"}