Catalog plugin API (Spark)
| Also known as | CatalogPlugin, Spark multi-catalog API, DSV2 catalog API |
|---|---|
| Field | Metadata management in query engines |
| Key parts | CatalogPlugin, TableCatalog, SupportsNamespaces, StagingTableCatalog, FunctionCatalog, ViewCatalog, ProcedureCatalog, CatalogExtension |
| Open source implementations | Apache Spark; catalogs from Apache Iceberg, Delta Lake, Unity Catalog |
| Related | Data Source V2, Data catalog, Hive Metastore, Iceberg REST catalog |
In Apache Spark, the catalog plugin API is the part of Data Source V2 that lets an external catalog register under a name and serve namespaces, tables, views, functions and procedures to Spark SQL; its root interface is org.apache.spark.sql.connector.catalog.CatalogPlugin.[1] It is how Apache Iceberg, Delta Lake and Unity Catalog plug into Spark,[2][3][4] and it allows one Spark session to query tables from several catalogs with three-part names such as catalog.schema.table.
What is CatalogPlugin?
CatalogPlugin is a marker interface with three methods: initialize(name, options), name() and a default defaultNamespace(). Spark loads the class through a required public no-argument constructor and then calls initialize once.[1] The interface has been part of Spark since 3.0.0 and is annotated @Evolving.[1] The Spark 3.0.0 release notes list it as "Catalog plugin API" (SPARK-31121).[5]
How is a catalog registered?
A catalog is registered with the configuration key spark.sql.catalog.<name>, whose value is the implementing class. Every key of the form spark.sql.catalog.<name>.<key> is passed to initialize in a case-insensitive map with the prefix removed.[1] For example, spark.sql.catalog.lake.type=rest reaches the catalog named lake as the option type=rest.
Two settings control defaults. spark.sql.defaultCatalog names the current catalog when none has been set, and defaults to spark_catalog.[6] spark.sql.catalog.spark_catalog sets the implementation of the built-in session catalog; its default, builtin, is Spark's own V2SessionCatalog, and a replacement must stay consistent with the built-in catalog, typically by extending CatalogExtension.[6]
What does TableCatalog add?
A plugin gains abilities by implementing more interfaces. TableCatalog extends CatalogPlugin with listTables, loadTable, createTable, alterTable, dropTable and related methods, and returns Table objects that Spark reads and writes through Data Source V2.[7]
TableCatalog also carries time travel. Overloads loadTable(ident, String version) and loadTable(ident, long timestamp), with the timestamp in microseconds since the Unix epoch, return a table at a past state; the default implementations throw a "no such table" error, so a catalog supports time travel only if it overrides them.[8] An overload that receives the write privileges a statement needs was added in 3.5.3.[8]
| Interface | Adds | Since |
|---|---|---|
TableCatalog |
Table lifecycle: list, load, create, alter, drop | 3.0.0[8] |
SupportsNamespaces |
Namespace (database or schema) DDL | 3.0.0[9] |
StagingTableCatalog |
Atomic CREATE TABLE AS SELECT and REPLACE TABLE AS SELECT through staged tables |
3.0.0[10] |
CatalogExtension, DelegatingCatalogExtension |
Wrap the built-in session catalog and delegate to it | 3.0.0[11] |
FunctionCatalog |
List and load user-defined functions | 3.2.0[12] |
ProcedureCatalog |
Stored procedures called with CALL |
4.0.0[13] |
ViewCatalog |
View DDL and view reads | 4.2.0[14] |
The built-in session catalog is not a ViewCatalog; views in spark_catalog still use the V1, Hive-compatible code path, and V2 view support applies to catalogs registered under their own names.[7]
How do Iceberg, Delta Lake and Unity Catalog register catalogs?
Apache Iceberg provides two classes. org.apache.iceberg.spark.SparkCatalog is a standalone catalog backed by a Hive, Hadoop, REST, Glue, JDBC or Nessie catalog, selected with an option such as type=rest. org.apache.iceberg.spark.SparkSessionCatalog replaces spark_catalog, serves Iceberg tables itself and delegates other tables to Spark's built-in catalog.[2] In the Iceberg 1.12.0 source, SparkSessionCatalog implements CatalogExtension, and the shared base class of both implements StagingTableCatalog, ProcedureCatalog and SupportsNamespaces.[15][16]
Delta Lake replaces the session catalog. Its documentation sets spark.sql.catalog.spark_catalog to org.apache.spark.sql.delta.catalog.DeltaCatalog, together with spark.sql.extensions=io.delta.sql.DeltaSparkSessionExtension.[3] In the Delta Lake v4.4.1 source, DeltaCatalog derives from AbstractDeltaCatalog, which extends Spark's DelegatingCatalogExtension, so non-Delta tables fall through to the built-in catalog.[17]
Unity Catalog OSS registers a named catalog with io.unitycatalog.spark.UCSingleCatalog, plus uri and authentication options under the same prefix, and its guide makes that catalog the default with spark.sql.defaultCatalog. The same guide also configures Delta Lake's extension and DeltaCatalog.[4] In the 0.7.0 source, UCSingleCatalog implements StagingTableCatalog and SupportsNamespaces.[18]
Example
The connector releases cited on this page do not all support Spark 4.3. Delta Lake 4.4.1 is built for Spark 4.0.1, 4.1.0 and 4.2.0,[19] Unity Catalog 0.7.0 publishes Spark connectors for Spark 4.0.x, 4.1.x and 4.2.x,[20] and Iceberg 1.12.0 publishes Spark runtimes for Spark 3.5, 4.0 and 4.1.[21] The newest Spark line that all three support is therefore 4.1.
The following PySpark session targets Spark 4.1 with Scala 2.13. It puts Delta Lake in the session catalog and adds an Iceberg REST catalog named lake and a Unity Catalog catalog named unity. Class names and option keys follow the cited project docs.[2][3][4]
from pyspark.sql import SparkSession
spark = (
SparkSession.builder
# Spark 4.1, Scala 2.13
.config("spark.jars.packages", ",".join([
"io.delta:delta-spark_4.1_2.13:4.4.1",
"org.apache.iceberg:iceberg-spark-runtime-4.1_2.13:1.12.0",
"io.unitycatalog:unitycatalog-spark_4.1_2.13:0.7.0",
]))
.config("spark.sql.extensions", "io.delta.sql.DeltaSparkSessionExtension")
.config("spark.sql.catalog.spark_catalog",
"org.apache.spark.sql.delta.catalog.DeltaCatalog")
.config("spark.sql.catalog.lake", "org.apache.iceberg.spark.SparkCatalog")
.config("spark.sql.catalog.lake.type", "rest")
.config("spark.sql.catalog.lake.uri", "http://localhost:8181") # Iceberg REST server
.config("spark.sql.catalog.unity", "io.unitycatalog.spark.UCSingleCatalog")
.config("spark.sql.catalog.unity.uri", "http://localhost:8080")
.config("spark.sql.catalog.unity.auth.type", "static")
.config("spark.sql.catalog.unity.auth.token", "<token>")
.getOrCreate()
)
spark.sql("SELECT * FROM lake.sales.orders LIMIT 10").show()
spark.sql("SHOW NAMESPACES IN unity").show()
Catalog plugin vs. Hive Metastore
The catalog plugin API is an interface inside Spark; a Hive Metastore is a metadata service. Spark's built-in spark_catalog can be backed by a Hive Metastore, and plugins such as Iceberg's SparkCatalog with type=hive can use one as their store, but the plugin decides how names map to tables.[2] See Data catalog for the broader term.
See also
References
- ↑ 1.0 1.1 1.2 1.3 CatalogPlugin.java (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ 2.0 2.1 2.2 2.3 Spark Configuration (Apache Iceberg 1.12.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ 3.0 3.1 3.2 Table batch reads and writes. Delta Lake (Linux Foundation).Retrieved 2026-11-23.
- ↑ 4.0 4.1 4.2 Unity Catalog Apache Spark integration. Unity Catalog (LF AI & Data).Retrieved 2026-11-23.
- ↑ Spark Release 3.0.0. Apache Software Foundation.Retrieved 2026-11-23.
- ↑ 6.0 6.1 SQLConf.scala (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ 7.0 7.1 Data Source V2 (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ 8.0 8.1 8.2 TableCatalog.java (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ SupportsNamespaces.java (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ StagingTableCatalog.java (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ CatalogExtension.java (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ FunctionCatalog.java (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ ProcedureCatalog.java (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ ViewCatalog.java (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ SparkSessionCatalog.java (apache-iceberg-1.12.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ BaseCatalog.java (apache-iceberg-1.12.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ AbstractDeltaCatalog.scala (v4.4.1). Delta Lake (Linux Foundation).Retrieved 2026-11-23.
- ↑ UCSingleCatalog.scala (v0.7.0). Unity Catalog (LF AI & Data).Retrieved 2026-11-23.
- ↑ Delta Lake 4.4.1. delta-io on GitHub.Retrieved 2026-11-23.
- ↑ Unity Catalog v0.7.0. unitycatalog on GitHub.Retrieved 2026-11-23.
- ↑ iceberg-spark-runtime-4.1_2.13 1.12.0. Maven Central.Retrieved 2026-11-23.