<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Spark_3_to_Spark_4_migration</id>
	<title>Spark 3 to Spark 4 migration - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Spark_3_to_Spark_4_migration"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_3_to_Spark_4_migration&amp;action=history"/>
	<updated>2026-12-06T00:08:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://openlakehouse.io/w/index.php?title=Spark_3_to_Spark_4_migration&amp;diff=104&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@f2492a3</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_3_to_Spark_4_migration&amp;diff=104&amp;oldid=prev"/>
		<updated>2026-11-23T00:34:54Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@f2492a3&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox concept&lt;br /&gt;
| name            = Spark 3 to Spark 4 migration&lt;br /&gt;
| also_known_as   = Upgrading from Spark 3.5 to 4.0&lt;br /&gt;
| field           = Distributed data processing&lt;br /&gt;
| key_parts       = ANSI SQL mode by default, Java 17 and Scala 2.13 only, Python 3.9 minimum, removed Mesos support, deprecated SparkR&lt;br /&gt;
| implementations = [[Apache Spark]] 4.0.0 (released 2025-05-23)&lt;br /&gt;
| related         = [[Spark Connect]], [[SparkR]], [[Apache Mesos support in Spark]], [[Scala 2.12 and 2.13 in Spark]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-22|the v3.5.0, v4.0.0, v4.1.0, v4.2.0 and v4.3.0 tags of apache/spark (docs/index.md, docs/sql-migration-guide.md, docs/core-migration-guide.md, python/docs/source/migration_guide/pyspark_upgrade.rst, SQLConf.scala), the Spark 4.0.0 release notes, the Spark news page and the Spark versioning policy}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Spark 3 to Spark 4 migration&amp;#039;&amp;#039;&amp;#039; is the work of moving [[Apache Spark]] applications from the 3.x line (in practice 3.5) to Spark 4.0 or later, the first major release since 3.0. Spark 4.0.0 was released on 23 May 2025.&amp;lt;ref name=&amp;quot;news&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/news/index.html |title=News |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; The changes most likely to break an upgrade are platform minimums (Java 17, Scala 2.13 only, Python 3.9) and the switch of Spark SQL to ANSI mode by default, which turns many silent nulls and overflows into runtime errors.&amp;lt;ref name=&amp;quot;r400&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/releases/spark-release-4-0-0.html |title=Spark Release 4.0.0 |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; Spark 4.0 also removed Apache Mesos support and deprecated SparkR. This page summarizes those changes from the official migration guides; it does not replace them.&lt;br /&gt;
&lt;br /&gt;
== Platform requirements ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! !! Spark 3.5 !! Spark 4.0 !! Spark 4.3&lt;br /&gt;
|-&lt;br /&gt;
! Java&lt;br /&gt;
| 8, 11, 17 || 17, 21 || 17, 21, 25&lt;br /&gt;
|-&lt;br /&gt;
! Scala&lt;br /&gt;
| 2.12, 2.13 || 2.13 || 2.13&lt;br /&gt;
|-&lt;br /&gt;
! Python&lt;br /&gt;
| 3.8+ || 3.9+ || 3.11+&lt;br /&gt;
|-&lt;br /&gt;
! R (SparkR)&lt;br /&gt;
| 3.5+ || 3.5+ (deprecated) || 4.0+ (deprecated)&lt;br /&gt;
|}&lt;br /&gt;
Sources: the &amp;quot;Spark runs on&amp;quot; line of &amp;lt;code&amp;gt;docs/index.md&amp;lt;/code&amp;gt; at each tag.&amp;lt;ref name=&amp;quot;idx350&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v3.5.0/docs/index.md |title=docs/index.md at v3.5.0 |publisher=GitHub (apache/spark) |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;idx400&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.0.0/docs/index.md |title=docs/index.md at v4.0.0 |publisher=GitHub (apache/spark) |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;idx430&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/docs/index.md |title=docs/index.md at v4.3.0 |publisher=GitHub (apache/spark) |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; Spark 4.1 raised the Python minimum to 3.10, and Spark 4.2 added Java 25.&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.1.0/docs/index.md |title=docs/index.md at v4.1.0 |publisher=GitHub (apache/spark) |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.2.0/docs/index.md |title=docs/index.md at v4.2.0 |publisher=GitHub (apache/spark) |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Java.&amp;#039;&amp;#039;&amp;#039; SPARK-45315 dropped JDK 8 and 11 and made JDK 17 the default.&amp;lt;ref name=&amp;quot;r400&amp;quot; /&amp;gt; Hive metastore clients older than Hive 2.0.0 are no longer supported, because they need JDK 8.&amp;lt;ref name=&amp;quot;sqlmig&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.0.0/docs/sql-migration-guide.md |title=Migration Guide: SQL, Datasets and DataFrame (docs/sql-migration-guide.md at v4.0.0) |publisher=GitHub (apache/spark) |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Scala.&amp;#039;&amp;#039;&amp;#039; SPARK-45314 dropped Scala 2.12 and made 2.13 the default. Applications and libraries compiled for Scala 2.12 must be rebuilt for 2.13.&amp;lt;ref name=&amp;quot;r400&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;idx400&amp;quot; /&amp;gt; See [[Scala 2.12 and 2.13 in Spark]].&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Python.&amp;#039;&amp;#039;&amp;#039; SPARK-47993 dropped Python 3.8. PySpark 4.0 also raised the minimum versions of pandas to 2.0.0, NumPy to 1.21 and PyArrow to 11.0.0.&amp;lt;ref name=&amp;quot;pymig&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.0.0/python/docs/source/migration_guide/pyspark_upgrade.rst |title=Upgrading PySpark (pyspark_upgrade.rst at v4.0.0) |publisher=GitHub (apache/spark) |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ANSI SQL mode by default ==&lt;br /&gt;
SPARK-44444 made Spark SQL use ANSI mode by default.&amp;lt;ref name=&amp;quot;r400&amp;quot; /&amp;gt; In Spark 4.0, &amp;lt;code&amp;gt;spark.sql.ansi.enabled&amp;lt;/code&amp;gt; defaults to true unless the environment variable &amp;lt;code&amp;gt;SPARK_ANSI_SQL_MODE&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;conf&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.0.0/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala |title=SQLConf.scala at v4.0.0 |publisher=GitHub (apache/spark) |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; In ANSI mode Spark throws an error at runtime, instead of returning null, when the inputs to a SQL operator or function are invalid; examples are integer overflow and invalid casts from string to a number.&amp;lt;ref name=&amp;quot;conf&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.0.0/docs/sql-ref-ansi-compliance.md |title=ANSI Compliance (docs/sql-ref-ansi-compliance.md at v4.0.0) |publisher=GitHub (apache/spark) |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
-- Spark 3.5 default: returns NULL.  Spark 4.0 default: fails with a CAST_INVALID_INPUT error.&lt;br /&gt;
SELECT CAST(&amp;#039;abc&amp;#039; AS INT);&lt;br /&gt;
&lt;br /&gt;
-- Works in both: try_cast returns NULL for invalid input.&lt;br /&gt;
SELECT try_cast(&amp;#039;abc&amp;#039; AS INT);&lt;br /&gt;
&lt;br /&gt;
-- Restore the Spark 3 behaviour for a session.&lt;br /&gt;
SET spark.sql.ansi.enabled = false;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pipelines that relied on silent nulls should move to the &amp;lt;code&amp;gt;try_*&amp;lt;/code&amp;gt; functions or fix the data, rather than turning ANSI mode off everywhere. The pandas API on Spark is a special case: in Spark 4.0.0 it fails with a &amp;lt;code&amp;gt;PANDAS_API_ON_SPARK_FAIL_ON_ANSI_MODE&amp;lt;/code&amp;gt; error when ANSI mode is on, unless the pandas-on-Spark option &amp;lt;code&amp;gt;compute.fail_on_ansi_mode&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; (SPARK-52026).&amp;lt;ref&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-52026 |title=SPARK-52026: Block pandas API on Spark on ANSI mode by default |publisher=Apache Software Foundation JIRA |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other SQL behaviour changes ==&lt;br /&gt;
The Spark 3.5 to 4.0 section of the SQL migration guide lists many changes. Among those most likely to matter in a lakehouse:&amp;lt;ref name=&amp;quot;sqlmig&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Change in Spark 4.0 !! Setting to restore the old behaviour&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;CREATE TABLE&amp;lt;/code&amp;gt; without &amp;lt;code&amp;gt;USING&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;STORED AS&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;spark.sql.sources.default&amp;lt;/code&amp;gt; (Parquet by default) instead of Hive. || &amp;lt;code&amp;gt;spark.sql.legacy.createHiveTableByDefault=true&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| The default ORC compression codec changed from &amp;lt;code&amp;gt;snappy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;zstd&amp;lt;/code&amp;gt;. || &amp;lt;code&amp;gt;spark.sql.orc.compression.codec=snappy&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.sql.maxSinglePartitionBytes&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;128m&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;Long.MaxValue&amp;lt;/code&amp;gt;. || Set it to &amp;lt;code&amp;gt;9223372036854775807&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| The &amp;lt;code&amp;gt;spark.sql.legacy.*&amp;lt;/code&amp;gt; datetime rebase configs for Parquet and Avro were removed. || Use the same names without &amp;lt;code&amp;gt;legacy.&amp;lt;/code&amp;gt;, for example &amp;lt;code&amp;gt;spark.sql.parquet.int96RebaseModeInWrite&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.sql.legacy.timeParserPolicy&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;CORRECTED&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;EXCEPTION&amp;lt;/code&amp;gt;. || Set it back to &amp;lt;code&amp;gt;EXCEPTION&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Views tolerate column type changes in the underlying query and compensate with casts. || &amp;lt;code&amp;gt;spark.sql.legacy.viewSchemaCompensation=false&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| JDBC type mappings changed for PostgreSQL, MySQL, Oracle, SQL Server and DB2 (for example timestamps and small integer types). || Per-database &amp;lt;code&amp;gt;spark.sql.legacy.*&amp;lt;/code&amp;gt; flags listed in the guide&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Core and cluster changes ==&lt;br /&gt;
From the core migration guide for 3.5 to 4.0:&amp;lt;ref name=&amp;quot;coremig&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.0.0/docs/core-migration-guide.md |title=Migration Guide: Spark Core (docs/core-migration-guide.md at v4.0.0) |publisher=GitHub (apache/spark) |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Support for Apache Mesos as a resource manager was removed (SPARK-44442).&amp;lt;ref name=&amp;quot;r400&amp;quot; /&amp;gt; See [[Apache Mesos support in Spark]].&lt;br /&gt;
* Internal servlet API references moved from &amp;lt;code&amp;gt;javax&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;jakarta&amp;lt;/code&amp;gt;, which affects custom UI and servlet code.&lt;br /&gt;
* Event logs are rolled and compressed by default (&amp;lt;code&amp;gt;spark.eventLog.rolling.enabled&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;spark.eventLog.compress&amp;lt;/code&amp;gt;).&lt;br /&gt;
* Speculative execution is less aggressive: &amp;lt;code&amp;gt;spark.speculation.multiplier=3&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;spark.speculation.quantile=0.9&amp;lt;/code&amp;gt;.&lt;br /&gt;
* On Kubernetes, executor pods are allocated in batches of 10, and persistent volume claims use &amp;lt;code&amp;gt;ReadWriteOncePod&amp;lt;/code&amp;gt;.&lt;br /&gt;
* The default Ivy user directory is &amp;lt;code&amp;gt;~/.ivy2.5.2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Removed and deprecated APIs ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Item !! Status in Spark 4.0 !! Source&lt;br /&gt;
|-&lt;br /&gt;
| Apache Mesos resource manager || Removed || SPARK-44442&amp;lt;ref name=&amp;quot;r400&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Scala 2.12 builds || Removed || SPARK-45314&amp;lt;ref name=&amp;quot;r400&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Java 8 and 11 || No longer supported || SPARK-45315&amp;lt;ref name=&amp;quot;r400&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[SparkR]] || Deprecated, still shipped (the &amp;lt;code&amp;gt;R&amp;lt;/code&amp;gt; directory is present at the v4.3.0 tag) || SPARK-49347&amp;lt;ref name=&amp;quot;r400&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;idx430&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Hive metastore versions before 2.0.0 || Removed || SPARK-45328&amp;lt;ref name=&amp;quot;r400&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Deprecated pandas API on Spark methods (for example &amp;lt;code&amp;gt;DataFrame.append&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;iteritems&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to_koalas&amp;lt;/code&amp;gt;) || Removed || PySpark migration guide&amp;lt;ref name=&amp;quot;pymig&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;pyspark.ml.connect&amp;lt;/code&amp;gt; || Deprecated in favour of &amp;lt;code&amp;gt;pyspark.ml&amp;lt;/code&amp;gt; on Spark Connect || SPARK-50828&amp;lt;ref name=&amp;quot;r400&amp;quot; /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Spark Connect in Spark 4 ==&lt;br /&gt;
Spark 4.0 is the first major release in which [[Spark Connect]] is close to the classic API. The release notes list Scala client parity with the Dataset and DataFrame API, &amp;lt;code&amp;gt;pyspark.ml&amp;lt;/code&amp;gt; support on Connect, a lightweight &amp;lt;code&amp;gt;pyspark-client&amp;lt;/code&amp;gt; Python package, an extra release tarball with Connect enabled by default, and the &amp;lt;code&amp;gt;spark.api.mode&amp;lt;/code&amp;gt; setting to switch an application between classic and Connect.&amp;lt;ref name=&amp;quot;r400&amp;quot; /&amp;gt; A migration is therefore a natural point to check whether code uses APIs that Connect does not have, such as RDDs and &amp;lt;code&amp;gt;SparkContext&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Timing ==&lt;br /&gt;
Spark 3.5 has an extended long-term support period that ends in November 2027, during which only security fixes are released.&amp;lt;ref name=&amp;quot;policy&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/versioning-policy.html |title=Versioning policy |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; Non-LTS release branches are generally maintained with bug fix releases for six months, and the policy names Spark 4.5.0 as the planned LTS release of the 4.x line.&amp;lt;ref name=&amp;quot;policy&amp;quot; /&amp;gt; Later 4.x releases have their own migration sections (4.0 to 4.1, 4.1 to 4.2, 4.2 to 4.3) in the same guide.&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/docs/sql-migration-guide.md |title=docs/sql-migration-guide.md at v4.3.0 |publisher=GitHub (apache/spark) |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Apache Spark]]&lt;br /&gt;
* [[Spark Connect]]&lt;br /&gt;
* [[SparkR]]&lt;br /&gt;
* [[Apache Mesos support in Spark]]&lt;br /&gt;
* [[Scala 2.12 and 2.13 in Spark]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Navbox open lakehouse}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Apache Spark]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>