{"record":{"id":"a84f37f2a79ed266","repo":"apache/iceberg","slug":"invalid-session-catalog-sparksessioncatalog","errorCode":null,"errorMessage":"Invalid session catalog: sparkSessionCatalog","messagePattern":"Invalid session catalog: sparkSessionCatalog","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java","lineNumber":369,"sourceCode":"      return;\n    }\n\n    Preconditions.checkArgument(\n        catalogHmsUri.equals(envHmsUri),\n        \"Inconsistent Hive metastore URIs: %s (Spark session) != %s (spark_catalog)\",\n        envHmsUri,\n        catalogHmsUri);\n  }\n\n  @Override\n  @SuppressWarnings(\"unchecked\")\n  public void setDelegateCatalog(CatalogPlugin sparkSessionCatalog) {\n    if (sparkSessionCatalog instanceof TableCatalog\n        && sparkSessionCatalog instanceof FunctionCatalog\n        && sparkSessionCatalog instanceof SupportsNamespaces) {\n      this.sessionCatalog = (T) sparkSessionCatalog;\n    } else {\n      throw new IllegalArgumentException(\"Invalid session catalog: \" + sparkSessionCatalog);\n    }\n  }\n\n  @Override\n  public String name() {\n    return catalogName;\n  }\n\n  private boolean useIceberg(String provider) {\n    if (provider == null || \"iceberg\".equalsIgnoreCase(provider)) {\n      return true;\n    } else if (createParquetAsIceberg && \"parquet\".equalsIgnoreCase(provider)) {\n      return true;\n    } else if (createAvroAsIceberg && \"avro\".equalsIgnoreCase(provider)) {\n      return true;\n    } else if (createOrcAsIceberg && \"orc\".equalsIgnoreCase(provider)) {\n      return true;\n    }","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java#L351-L387","documentation":"Thrown by SparkSessionCatalog.setDelegateCatalog when the CatalogPlugin provided as the session (delegate) catalog does not simultaneously implement TableCatalog, FunctionCatalog, and SupportsNamespaces. The session catalog must be a full-featured catalog, so partial implementations are rejected at initialization.","triggerScenarios":"Configuring spark.sql.catalog.<name> (the delegate under spark.sql.catalog.spark_catalog delegate setup / setDelegateCatalog) with a plugin class that implements only some of TableCatalog, FunctionCatalog, SupportsNamespaces — e.g. a custom catalog lacking function support.","commonSituations":"Pointing SparkSessionCatalog at a third-party or custom CatalogPlugin; misconfigured spark_catalog delegation after upgrading Spark; using an old catalog implementation lacking FunctionCatalog; test code passing a stub catalog plugin.","solutions":["Configure a delegate catalog that implements all three interfaces: TableCatalog, FunctionCatalog, and SupportsNamespaces.","Use a built-in catalog (e.g. Spark's V2SessionCatalog or HiveCatalog) as the delegate.","Upgrade/fix the custom catalog implementation to add the missing interfaces.","Verify the class name in spark.sql.catalog.<session-catalog-name> is the intended implementation."],"exampleFix":"// before\nspark.conf.set(\"spark.sql.catalog.spark_catalog\", \"com.example.PartialCatalog\");\n// after\nspark.conf.set(\"spark.sql.catalog.spark_catalog\", \"org.apache.iceberg.spark.SparkSessionCatalog\");\nspark.conf.set(\"spark.sql.catalog.spark_catalog.catalog-impl\", \"org.apache.iceberg.hive.HiveCatalog\");","handlingStrategy":"validation","validationCode":"if (!(plugin instanceof TableCatalog && plugin instanceof FunctionCatalog && plugin instanceof SupportsNamespaces)) { throw new IllegalArgumentException(\"delegate catalog missing required interfaces\"); }","typeGuard":"boolean validDelegate = plugin instanceof TableCatalog && plugin instanceof FunctionCatalog && plugin instanceof SupportsNamespaces;","tryCatchPattern":"try { sessionCatalog.setDelegateCatalog(plugin); } catch (IllegalArgumentException e) { /* substitute a full-featured delegate catalog */ }","preventionTips":["Check the delegate class implements all three interfaces before wiring","Use built-in catalogs as delegates","Add an integration smoke test for catalog initialization"],"tags":["spark","catalog","invalid-argument","configuration"],"backgroundTag":"invalid-config-value","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"}