<?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=SparkContext</id>
	<title>SparkContext - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=SparkContext"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=SparkContext&amp;action=history"/>
	<updated>2026-12-06T00:13:44Z</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=SparkContext&amp;diff=184&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@7c9abaa</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=SparkContext&amp;diff=184&amp;oldid=prev"/>
		<updated>2026-11-25T00:52:52Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@7c9abaa&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            = SparkContext&lt;br /&gt;
| also_known_as   = &amp;lt;code&amp;gt;sc&amp;lt;/code&amp;gt; (the variable name in shells)&lt;br /&gt;
| field           = Distributed data processing&lt;br /&gt;
| key_parts       = Connection to the cluster manager, executors, DAG and task schedulers, RDD API, broadcast variables, accumulators, job groups and tags&lt;br /&gt;
| implementations = [[Apache Spark]] (Spark Classic only)&lt;br /&gt;
| related         = [[SparkSession]], [[Driver (Apache Spark)]], [[RDD]], [[Spark Connect]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the v4.3.0 tag of apache/spark (core SparkContext.scala, the Spark 2.0.0 release notes, docs/cluster-overview.md, docs/spark-connect-overview.md, docs/app-dev-spark-connect.md, python/pyspark/sql/connect/session.py, python/pyspark/sql/session.py, sql/api SparkSession.scala)}}&lt;br /&gt;
&lt;br /&gt;
In [[Apache Spark]], a &amp;#039;&amp;#039;&amp;#039;SparkContext&amp;#039;&amp;#039;&amp;#039; is the object in the [[Driver (Apache Spark)|driver]] that represents the connection to a Spark cluster; it acquires [[executor]]s, schedules work on them and is used to create [[RDD]]s, accumulators and broadcast variables.&amp;lt;ref name=&amp;quot;sc&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/SparkContext.scala |title=SparkContext.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; The source code still calls it the &amp;quot;main entry point for Spark functionality&amp;quot;, but since Spark 2.0.0 DataFrame and SQL code starts from a [[SparkSession]], which creates or reuses a SparkContext underneath.&amp;lt;ref name=&amp;quot;sc&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;r200&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/releases/spark-release-2-0-0.html |title=Spark Release 2.0.0 |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; In Spark 4 the SparkContext still runs every classic application, but [[Spark Connect]] clients cannot use it.&lt;br /&gt;
&lt;br /&gt;
== What does SparkContext still do in Spark 4? ==&lt;br /&gt;
SparkContext remains the core of a Spark Classic application in Spark 4.3.0. The cluster overview describes Spark applications as independent sets of processes coordinated by the SparkContext in the driver program: it connects to the cluster manager (standalone, YARN or Kubernetes), acquires executors, sends them the application code and then sends them tasks.&amp;lt;ref name=&amp;quot;cluster&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/cluster-overview.html |title=Cluster Mode Overview (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; DataFrame and SQL queries are planned by the [[SparkSession]] and then run as jobs submitted through this SparkContext.&lt;br /&gt;
&lt;br /&gt;
Only one SparkContext may be active per JVM. Creating a second one while the first is running fails with &amp;quot;Only one SparkContext should be running in this JVM (see SPARK-2243)&amp;quot;; the first must be stopped with &amp;lt;code&amp;gt;stop()&amp;lt;/code&amp;gt; before a new one is made.&amp;lt;ref name=&amp;quot;sc&amp;quot; /&amp;gt; A side effect of this design is isolation: each application has its own executors, so two applications cannot share in-memory data except through external storage.&amp;lt;ref name=&amp;quot;cluster&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The public API of SparkContext in Spark 4.3.0 still covers these areas:&amp;lt;ref name=&amp;quot;sc&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Area !! Examples of SparkContext methods&lt;br /&gt;
|-&lt;br /&gt;
| Creating RDDs || &amp;lt;code&amp;gt;parallelize&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;textFile&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;runJob&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Shared variables || &amp;lt;code&amp;gt;broadcast&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;longAccumulator&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Shipping dependencies || &amp;lt;code&amp;gt;addFile&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;addJar&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Grouping and cancelling jobs || &amp;lt;code&amp;gt;setJobGroup&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cancelJobGroup&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;setLocalProperty&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Inspecting the application || &amp;lt;code&amp;gt;applicationId&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;uiWebUrl&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;statusTracker&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;defaultParallelism&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;setLogLevel&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Fault tolerance for long lineages || &amp;lt;code&amp;gt;setCheckpointDir&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In PySpark Classic, &amp;lt;code&amp;gt;spark.sparkContext&amp;lt;/code&amp;gt; returns the SparkContext behind a session. Code that uses only DataFrames and SQL seldom needs it; code that uses the RDD API, accumulators or &amp;lt;code&amp;gt;sc.setJobGroup&amp;lt;/code&amp;gt; does.&lt;br /&gt;
&lt;br /&gt;
== Why do Spark Connect clients not have a SparkContext? ==&lt;br /&gt;
A Spark Connect client does not run in the same process as the Spark driver. It builds logical plans and sends them to a Spark Connect server, which runs the driver and its SparkContext. The Spark Connect overview lists two consequences: the protocol, which is built on logical plans, does not support all of Spark&amp;#039;s execution APIs, &amp;quot;most importantly RDDs&amp;quot;; and the client, which gets a session rather than the whole application, has no access to the static Spark configuration or the SparkContext.&amp;lt;ref name=&amp;quot;connect&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/spark-connect-overview.html |title=Spark Connect Overview (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reason is that one server&amp;#039;s SparkContext serves many client sessions. The overview explains that a Connect client gets a session-based interface and has no access to properties that change the environment for all connected clients, the SparkContext above all.&amp;lt;ref name=&amp;quot;connect&amp;quot; /&amp;gt; In PySpark 4.3.0, reading &amp;lt;code&amp;gt;spark.sparkContext&amp;lt;/code&amp;gt; on a Connect session raises &amp;lt;code&amp;gt;JVM_ATTRIBUTE_NOT_SUPPORTED&amp;lt;/code&amp;gt;, and the Scala API marks &amp;lt;code&amp;gt;SparkSession.sparkContext&amp;lt;/code&amp;gt; as &amp;lt;code&amp;gt;@ClassicOnly&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;connsession&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/python/pyspark/sql/connect/session.py |title=connect/session.py (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;scalasession&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/api/src/main/scala/org/apache/spark/sql/SparkSession.scala |title=SparkSession.scala, sql/api (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What replaces SparkContext calls in Spark Connect? ==&lt;br /&gt;
The Spark Connect application guide says that RDDs can no longer be used directly from Spark Connect clients, and that alternatives for missing RDD functionality are provided in the higher-level APIs.&amp;lt;ref name=&amp;quot;appdev&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/app-dev-spark-connect.html |title=Application Development with Spark Connect (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; For common SparkContext calls, the [[SparkSession]] has methods that work over Spark Connect:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! SparkContext usage !! Session-level alternative&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sc.parallelize(data)&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;spark.createDataFrame(data)&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;spark.range(n)&amp;lt;/code&amp;gt;, which build a DataFrame instead of an RDD&amp;lt;ref name=&amp;quot;pysession&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/python/pyspark/sql/session.py |title=session.py (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sc.addFile&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sc.addPyFile&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;spark.addArtifacts(...)&amp;lt;/code&amp;gt;&amp;lt;ref name=&amp;quot;pysession&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sc.setJobGroup&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sc.cancelJobGroup&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;spark.addTag(tag)&amp;lt;/code&amp;gt;, then &amp;lt;code&amp;gt;spark.interruptTag(tag)&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;spark.interruptAll()&amp;lt;/code&amp;gt;&amp;lt;ref name=&amp;quot;pysession&amp;quot; /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The session-level methods in this table work in both Connect and Classic sessions since Spark 4.0.0, so code that uses them runs in either mode.&amp;lt;ref name=&amp;quot;pysession&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[SparkSession]]&lt;br /&gt;
* [[Spark Connect]]&lt;br /&gt;
* [[Driver (Apache Spark)]]&lt;br /&gt;
* [[RDD]]&lt;br /&gt;
* [[Job, stage and task]]&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:Concepts]]&lt;br /&gt;
[[Category:Glossary terms]]&lt;br /&gt;
[[Category:Apache Spark]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>