Skip to main content

Spark cannot find Iceberg: catalog plugin class errors

A Spark session that cannot see Iceberg starts normally and fails at the first statement that needs Iceberg. With no runtime jar, a query on an Iceberg catalog stops with Cannot find catalog plugin class for catalog 'demo': org.apache.iceberg.spark.SparkCatalog, and spark.read.format("iceberg") stops with Failed to find data source: iceberg.

This page is written by the team behind OLake Go, which writes Apache Iceberg tables. The steps apply to tables written by any engine. OLake is not affiliated with the Apache Software Foundation.

The short answer. Spark needs three things to see Iceberg, and each error on this page points at one of them:

  • The runtime jar built for your Spark minor version and Scala version, named iceberg-spark-runtime-<spark minor>_<scala version>.
  • A catalog defined with spark.sql.catalog.<name> and its type, used in queries as <name>.<namespace>.<table>.
  • The SQL extensions on Spark 3: spark.sql.extensions set to org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions.

A plugin class or data source error means no jar, NoSuchMethodError or NoClassDefFoundError means the wrong jar, and a namespace error means a catalog name the session does not have.

Key takeaways

  • Spark needs three things to see Iceberg: the runtime jar, a catalog, and the SQL extensions. Each error on this page points at one of them.
  • A jar built for the wrong Spark minor version can start cleanly and fail later. On Spark 3.5.6 the Spark 3.4 jar created, read and deleted rows, and failed only at MERGE, UPDATE and CALL.
  • What needs the extensions depends on the Spark version. Without them, Spark 3.3.3 refused MERGE and UPDATE, Spark 3.5.6 refused only CALL, and Spark 4.0.5 ran all four.

What you see​

On Spark 3.5.6, with the catalog demo configured and no runtime jar, the session started and the first query on demo failed:

org.apache.spark.SparkException: Cannot find catalog plugin class for catalog 'demo': org.apache.iceberg.spark.SparkCatalog.
Caused by: java.lang.ClassNotFoundException: org.apache.iceberg.spark.SparkCatalog

In every case on this page the session started, and the failure came at a statement. Each issue below gives the setup, the error and the fix.

The same failures across versions​

What is wrongSpark 3.3.3, Iceberg 1.4.3Spark 3.5.6, Iceberg 1.12.0Spark 4.0.5, Iceberg 1.12.0
No jar, query on the catalogCannot find catalog plugin class for catalog 'demo': org.apache.iceberg.spark.SparkCatalogSame, with a period at the endSame as 3.5.6
No jar, format("iceberg") or USING icebergFailed to find data source: iceberg. Please find packages at ...[DATA_SOURCE_NOT_FOUND] Failed to find the data source: iceberg. Please find packages at ...[DATA_SOURCE_NOT_FOUND] Failed to find the data source: iceberg. Make sure the provider name is correct and the package is properly registered and compatible with your Spark version. SQLSTATE: 42K02
No extensions, MERGE or UPDATEMERGE INTO TABLE is not supported temporarily.RanRan
No extensions, CALLSyntax error at or near 'CALL'[PARSE_SYNTAX_ERROR] Syntax error at or near 'CALL'.Ran
Unknown catalog namespark_catalog requires a single-part namespace, but got [dmeo, db][REQUIRES_SINGLE_PART_NAMESPACE] spark_catalog requires a single-part namespace, but got ...Same as 3.5.6, ending with SQLSTATE: 42K05
CALL on an unknown catalog nameCannot use catalog spark_catalog: not a ProcedureCatalogSameCatalog spark_catalog does not support procedures.
Misspelled spark.sql.defaultCatalogCatalog 'dmeo' plugin class not found: spark.sql.catalog.dmeo is not definedSame[CATALOG_NOT_FOUND] The catalog ... not found. Consider to set the SQL config ... to a catalog plugin.
USING iceberg in the built-in catalogCreated; reads and writes fail with iceberg is not a valid Spark SQL Data Source.SameCREATE fails with Cannot open table: path is not set

The three columns are from the runs on this page. Outside them, the Spark source at each release tag shows where the wording changed. The plugin class message is a plain string at 3.3.3 and the legacy error class _LEGACY_ERROR_TEMP_2215 from 3.4.4 to 4.1.0.

DATA_SOURCE_NOT_FOUND replaced the older wording in 3.4.0, and its second sentence changed in 4.0.0. The message <ddl> is not supported temporarily. is _LEGACY_ERROR_TEMP_2096 from 3.4.4 to 4.0.0 and is gone from the 4.1.0 file, and CATALOG_NOT_FOUND is absent at 3.5.6 and present from 4.0.0. Spark 3.4 and 4.1 were not run here.

How Spark loads Iceberg​

Spark loads Iceberg in three separate places, and each can be missing on its own:

SettingWhat it does
The runtime jarHolds the Iceberg classes
spark.sql.catalog.<name>Tells Spark which class to load as the catalog called <name>
spark.sql.extensionsAdds Iceberg's parser and planner rules to the session

Spark builds a catalog only when a statement first uses its name, so a broken catalog setting does not stop the session from starting. In the run on Spark 3.5.6, SHOW CATALOGS listed only spark_catalog before the first query and spark_catalog and demo after it.

Versions on this page

The runs used Spark 3.3.3 (Scala 2.12, Java 11) with Iceberg 1.4.3, Spark 3.5.6 (Scala 2.12, Java 17) with Iceberg 1.12.0, and Spark 4.0.5 (Scala 2.13, Java 17) with Iceberg 1.12.0. Each run used a REST catalog named demo and the Iceberg table demo.db.events (id bigint, kind string), and most steps ran CREATE TABLE, INSERT, MERGE, UPDATE, DELETE and CALL on it.

Issue 1: No runtime jar on the class path​

The session had the catalog demo and the extensions configured, and no runtime jar. It started on all three versions. A query on demo failed with the plugin class error.

A DataFrame read with format("iceberg"), or a table created USING iceberg, names the data source instead. The errors, by version:

The older wording, over three lines:

java.lang.ClassNotFoundException:
Failed to find data source: iceberg. Please find packages at
https://spark.apache.org/third-party-projects.html

On all three versions, the missing extensions class, which is in the same jar, is only a warning in the Spark log, and the session goes on without it:

WARN org.apache.spark.sql.SparkSession: Cannot use org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions to configure session extensions.
java.lang.ClassNotFoundException: org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions

Fix: put the runtime jar on the class path. On Spark 3.5.6 this configuration ran CREATE TABLE, INSERT, MERGE, UPDATE, DELETE, CALL and a DataFrame read. The AWS bundle provides S3FileIO for the object store.

bash
spark-submit \
--packages org.apache.iceberg:iceberg-spark-runtime-3.5_2.12:1.12.0,org.apache.iceberg:iceberg-aws-bundle:1.12.0 \
--conf spark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions \
--conf spark.sql.catalog.demo=org.apache.iceberg.spark.SparkCatalog \
--conf spark.sql.catalog.demo.type=rest \
--conf spark.sql.catalog.demo.uri=http://rest:8181 \
--conf spark.sql.catalog.demo.io-impl=org.apache.iceberg.aws.s3.S3FileIO \
--conf spark.sql.catalog.demo.s3.endpoint=http://minio:9000 \
--conf spark.sql.catalog.demo.s3.path-style-access=true \
job.py

The same settings in spark-defaults.conf, read from $SPARK_CONF_DIR, gave the same result with no options on the command line:

properties
spark.jars.packages org.apache.iceberg:iceberg-spark-runtime-3.5_2.12:1.12.0,org.apache.iceberg:iceberg-aws-bundle:1.12.0
spark.sql.extensions org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions
spark.sql.catalog.demo org.apache.iceberg.spark.SparkCatalog
spark.sql.catalog.demo.type rest
spark.sql.catalog.demo.uri http://rest:8181
spark.sql.catalog.demo.io-impl org.apache.iceberg.aws.s3.S3FileIO
spark.sql.catalog.demo.s3.endpoint http://minio:9000
spark.sql.catalog.demo.s3.path-style-access true

For the other two versions only the first line changes: iceberg-spark-runtime-3.3_2.12:1.4.3 with iceberg-aws-bundle:1.4.3 on Spark 3.3.3, and iceberg-spark-runtime-4.0_2.13:1.12.0 with iceberg-aws-bundle:1.12.0 on Spark 4.0.5. Both ran the same statements. The AWS credentials came from AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION in the environment.

Issue 2: A jar built for another Scala version​

The session had the right Spark minor version in the jar name but the wrong Scala version. These fail with Java linkage errors that do not mention Iceberg's version at all.

SparkJarResult
Spark 3.5.6 (Scala 2.12)iceberg-spark-runtime-3.5_2.13Every SQL statement failed
Spark 3.3.3 (Scala 2.12)iceberg-spark-runtime-3.3_2.13Every statement failed with java.lang.NoClassDefFoundError: scala/$less$colon$less, except MERGE, UPDATE and DELETE, which failed with NoSuchMethodError

On Spark 3.5.6 every statement failed, because the extensions parser handles each one:

java.lang.NoClassDefFoundError: scala/collection/SeqOps
at org.apache.spark.sql.catalyst.analysis.RewriteViewCommands.apply(RewriteViewCommands.scala:50)
Caused by: java.lang.ClassNotFoundException: scala.collection.SeqOps

Spark 4.0.5 was not run with another Scala version, because the 4.0 runtime is built for Scala 2.13 only.

Fix: read the Scala version from spark-submit --version and take the jar with it in the name:

/___/ .__/\_,_/_/ /_/\_\ version 3.5.6
Using Scala version 2.12.18, OpenJDK 64-Bit Server VM, 17.0.15

Issue 3: A jar built for another Spark minor version​

The runtime jar is built for one Spark minor version, because it uses Spark internals that change between minor versions. A jar for the wrong minor version did not always fail at once:

SparkJarResult
Spark 3.5.6Spark 3.4 jar, iceberg-spark-runtime-3.4_2.12:1.11.0Created, wrote, read and deleted rows; MERGE, UPDATE and CALL failed
Spark 4.0.5Spark 3.5 jar for Scala 2.13Every statement failed
Spark 4.0.5Spark 4.1 jarEvery statement failed
Spark 3.3.3Spark 3.5 jarFailed at once

The errors, by version:

The Spark 3.5 jar failed at once with the first error below, then with the second:

java.lang.IncompatibleClassChangeError: class org.apache.spark.sql.catalyst.plans.logical.OrderAwareCoalesce can not implement org.apache.spark.sql.catalyst.plans.logical.OrderPreservingUnaryNode, because it is not an interface
java.lang.NoClassDefFoundError: org/apache/spark/sql/connector/catalog/SupportsDeleteV2

Fix: read the Spark minor version from spark-submit --version, take the runtime jar with it in the name, and pick an Iceberg release that still ships that jar. The Iceberg multi-engine support page gives the naming: "For example, to use Iceberg with Spark 3.5 and AWS integrations, iceberg-spark-runtime-3.5_2.12 and AWS SDK dependencies are needed for the Spark installation." It lists the range:

SparkFirst Iceberg releaseLast Iceberg releaseRuntime jars
3.30.14.01.8.1iceberg-spark-runtime-3.3_2.12, iceberg-spark-runtime-3.3_2.13
3.41.3.01.11.0iceberg-spark-runtime-3.4_2.12, iceberg-spark-runtime-3.4_2.13
3.51.4.01.12.0iceberg-spark-runtime-3.5_2.12, iceberg-spark-runtime-3.5_2.13
4.01.10.01.12.0iceberg-spark-runtime-4.0_2.13
4.11.11.01.12.0iceberg-spark-runtime-4.1_2.13

The Java version matters too, and it was not tested here. The Iceberg release notes list "Build for Java 11 (#10849) - Removal of Java 8" under 1.7.0 and "Drop support for Java 11 (#14400)" under 1.11.0. A Spark image on Java 11 therefore needs Iceberg 1.10 or older.

Issue 4: No SQL extensions​

The session had the right jar and the catalog, and no spark.sql.extensions. What failed depended on the Spark version:

StatementSpark 3.3.3Spark 3.5.6Spark 4.0.5
MERGE, UPDATEFailed in the plannerRanRan
DELETERanRanRan
CALLFailed in the parserFailed in the parserRan

The errors, by version:

MERGE and UPDATE failed with:

java.lang.UnsupportedOperationException: MERGE INTO TABLE is not supported temporarily.
java.lang.UnsupportedOperationException: UPDATE TABLE is not supported temporarily.

DELETE ran. CALL failed with:

Syntax error at or near 'CALL'(line 1, pos 0)

== SQL ==
CALL demo.system.rewrite_data_files(table => 'db.events')
^^^

The Iceberg documentation states where Spark 4 differs: "For Spark 3.x, stored procedures are only available when using Iceberg SQL extensions in Spark. For Spark 4.0, stored procedures are supported natively without requiring the Iceberg SQL extensions. However, note that they are case-sensitive in Spark 4.0." (Spark procedures).

The Spark writes page still marks MERGE INTO and UPDATE with "Requires Iceberg Spark extensions". Spark 3.5.6 ran both without them in the run, so a working MERGE is not proof that the extensions are loaded. The same UPDATE TABLE is not supported temporarily. was reported on Spark 3.5 with Iceberg 1.5 in iceberg#9960, a setup this lab did not reproduce.

Fix: set spark.sql.extensions to org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions on every Spark version. With it, the SQL parser class (see Confirm the diagnosis) is org.apache.spark.sql.catalyst.parser.extensions.IcebergSparkSqlExtensionsParser; without it, org.apache.spark.sql.execution.SparkSqlParser.

Issue 5: A misspelled extensions class​

The session had spark.sql.extensions set to IcebergSparkSessionExtension, one letter short. All three versions logged a warning and ran exactly as without extensions (Issue 4):

WARN org.apache.spark.sql.SparkSession: Cannot use org.apache.iceberg.spark.extensions.IcebergSparkSessionExtension to configure session extensions.

Fix: check the spelling, IcebergSparkSessionExtensions, and look for this warning in the Spark log.

Issue 6: A catalog name the session does not have​

The session had the catalog demo, and the query was written as dmeo.db.events. Spark 3.5.6 answered:

[REQUIRES_SINGLE_PART_NAMESPACE] spark_catalog requires a single-part namespace, but got `dmeo`.`db`.

A name that is not a configured catalog is not an error by itself. Spark reads dmeo.db.events as the namespace dmeo.db in its built-in catalog, which allows one level of namespace, hence requires a single-part namespace. In the same way, USE dmeo gave [SCHEMA_NOT_FOUND] The schema `dmeo` cannot be found., and a procedure call on that name gave Cannot use catalog spark_catalog: not a ProcedureCatalog.

Fix: each spark.sql.catalog.<name> defines one catalog, and a three-part table name must start with that exact name. Compare the name in the failing statement with spark.sql.catalog.* in the session, and run SHOW CATALOGS after the first query, because it only lists catalogs that have been loaded.

Issue 7: A misspelled catalog class​

The session had spark.sql.catalog.demo=org.apache.iceberg.spark.SparkCatlog. On Spark 3.5.6 it produced the same message as a missing jar (Issue 1), with the misspelled name in it:

org.apache.spark.SparkException: Cannot find catalog plugin class for catalog 'demo': org.apache.iceberg.spark.SparkCatlog.
Caused by: java.lang.ClassNotFoundException: org.apache.iceberg.spark.SparkCatlog

Fix: read the class name in the message before adding jars. It must be org.apache.iceberg.spark.SparkCatalog.

Issue 8: A misspelled default catalog​

The session had spark.sql.defaultCatalog=dmeo, and every two-part table name, such as db.events, failed. Spark 3.3.3 and Spark 3.5.6 printed the first message below, and Spark 4.0.5 the second:

org.apache.spark.sql.connector.catalog.CatalogNotFoundException: Catalog 'dmeo' plugin class not found: spark.sql.catalog.dmeo is not defined
org.apache.spark.sql.connector.catalog.CatalogNotFoundException: [CATALOG_NOT_FOUND] The catalog `dmeo` not found. Consider to set the SQL config "spark.sql.catalog.dmeo" to a catalog plugin. SQLSTATE: 42P08

Fix: set spark.sql.defaultCatalog to a name defined with spark.sql.catalog.<name>, or write table names in three parts.

Issue 9: A catalog with a uri but no type​

The session had spark.sql.catalog.demo.uri set to the REST endpoint and no spark.sql.catalog.demo.type. Iceberg built a Hive catalog on all three versions, and it tried to talk the Hive Metastore protocol to the REST endpoint:

java.lang.RuntimeException: Failed to get table info from metastore db.events
Caused by: org.apache.thrift.transport.TTransportException

Spark 4.0.5 printed TTransportException: MaxMessageSize reached as the cause.

Fix: set the type, here spark.sql.catalog.demo.type=rest.

Issue 10: Iceberg tables in spark_catalog without SparkSessionCatalog​

The session had the runtime jar, and spark_catalog was Spark's own built-in catalog. CREATE TABLE default.t_session (id bigint) USING iceberg ran on Spark 3.3.3 and Spark 3.5.6, because the jar was there. Writing to the Iceberg table, reading it and deleting from it then failed on both:

org.apache.spark.sql.AnalysisException: iceberg is not a valid Spark SQL Data Source.

On Spark 4.0.5 the CREATE itself failed with Cannot open table: path is not set.

Fix: keep Iceberg tables in a separate catalog, spark.sql.catalog.demo=org.apache.iceberg.spark.SparkCatalog, as in Issue 1. Replace spark_catalog only when Iceberg and non-Iceberg tables must share one namespace. The Iceberg documentation puts it this way: "SparkSessionCatalog is useful when you want spark_catalog to work with both Iceberg and non-Iceberg tables in the same metastore." The configuration that ran on all three versions:

properties
spark.sql.catalog.spark_catalog org.apache.iceberg.spark.SparkSessionCatalog
spark.sql.catalog.spark_catalog.type rest
spark.sql.catalog.spark_catalog.uri http://rest:8181
spark.sql.catalog.spark_catalog.io-impl org.apache.iceberg.aws.s3.S3FileIO
spark.sql.catalog.spark_catalog.s3.endpoint http://minio:9000
spark.sql.catalog.spark_catalog.s3.path-style-access true

With it, db.events from the REST catalog was readable as a two-part name, an Iceberg table and a Parquet table were both created in db, and CALL spark_catalog.system.rewrite_data_files(...) ran. SHOW TABLES IN db listed only the Parquet table. The Iceberg tables were in the REST catalog and did not appear in that listing.

Issue 11: SparkSessionCatalog under another name​

The session had SparkSessionCatalog registered as demo instead of spark_catalog. It read the existing Iceberg table demo.db.events. A table that did not exist, SHOW TABLES and a Parquet table failed on all three versions:

java.lang.NullPointerException: Delegated SessionCatalog is missing. Please make sure your are replacing Spark's default catalog, named 'spark_catalog'.

Fix: register SparkSessionCatalog only under the name spark_catalog, as in Issue 10. For a catalog with another name, use SparkCatalog.

Confirm the diagnosis​

Check the versions first, then what the session loaded. spark-submit --version prints the Spark and Scala versions, which pick the jar (Issues 2 and 3).

From inside a PySpark session, these calls show the Iceberg build, the jars, the parser and where SparkCatalog came from. They are the calls the lab makes:

python
jvm = spark._jvm
print(f"Iceberg build: {jvm.org.apache.iceberg.IcebergBuild.fullVersion()}")
print(f"spark.jars = {spark.sparkContext.getConf().get('spark.jars', '<not set>')}")
print(f"SQL parser: {spark._jsparkSession.sessionState().sqlParser().getClass().getName()}")
loader = jvm.java.lang.Thread.currentThread().getContextClassLoader()
c = jvm.java.lang.Class.forName("org.apache.iceberg.spark.SparkCatalog", False, loader)
print(f"SparkCatalog loaded from: {c.getProtectionDomain().getCodeSource().getLocation().toString()}")

In the working run on Spark 3.5.6 they printed:

Iceberg build: Apache Iceberg 1.12.0 (commit 212aa894e919ff9fdf89160da4aadcbe6858ac01)
spark.jars = file:///ivy/jars/org.apache.iceberg_iceberg-spark-runtime-3.5_2.12-1.12.0.jar,file:///ivy/jars/org.apache.iceberg_iceberg-aws-bundle-1.12.0.jar
SQL parser: org.apache.spark.sql.catalyst.parser.extensions.IcebergSparkSqlExtensionsParser
SparkCatalog loaded from: file:/ivy/jars/org.apache.iceberg_iceberg-spark-runtime-3.5_2.12-1.12.0.jar

Without the extensions, the parser line read org.apache.spark.sql.execution.SparkSqlParser. With --packages, the driver log also shows what Ivy resolved, for example found org.apache.iceberg#iceberg-spark-runtime-3.5_2.12;1.12.0 in central.

One warning is not the cause. On Spark 3.3.3 with Iceberg 1.4.3, the working session printed ANTLR Tool version 4.9.3 used for code generation does not match the current runtime version 4.8 and then ran every statement. On Spark 4.0.5 the same warning, with 4.13.1 at the end, came with the Spark 3.5 jar, which did fail.

Prevent it​

  • Derive the runtime jar from spark-submit --version in the image or job definition, and change it in the same change as any Spark upgrade.
  • Pin the jar version in spark-defaults.conf or the job, not in individual notebooks.
  • Set the extensions on every Spark version. A working MERGE does not show that they are loaded; the parser class does.
  • Log IcebergBuild.fullVersion() and the parser class at the start of each job, so a mismatch shows up in the first line of the log.
  • Use one catalog name across jobs and write table names in three parts.
How OLake handles this

OLake Go's Iceberg writer runs as a Java process with a version requirement of its own: it needs Java 17 or later. On an older Java it stops with java.lang.UnsupportedClassVersionError: io/debezium/server/iceberg/OlakeRpcServer has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0, as the Iceberg writer troubleshooting page shows.

References​