<?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_plugin</id>
	<title>Spark plugin - 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_plugin"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_plugin&amp;action=history"/>
	<updated>2026-12-06T00:25:19Z</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_plugin&amp;diff=194&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=Spark_plugin&amp;diff=194&amp;oldid=prev"/>
		<updated>2026-11-25T00:52:56Z</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            = Spark plugin&lt;br /&gt;
| also_known_as   = SparkPlugin, driver plugin, executor plugin&lt;br /&gt;
| field           = Extension APIs&lt;br /&gt;
| key_parts       = SparkPlugin, DriverPlugin, ExecutorPlugin, PluginContext (metrics, configuration, driver RPC), spark.plugins&lt;br /&gt;
| implementations = [[Apache Spark]] (since 3.0.0)&lt;br /&gt;
| related         = [[Spark listener]], [[Executor]], [[Native execution engine (Spark)]], [[Apache Gluten]], [[DataFusion Comet]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the v4.3.0 tag of apache/spark (SparkPlugin.java, DriverPlugin.java, ExecutorPlugin.java, PluginContext.java, config/package.scala, docs/monitoring.md), Spark JIRA SPARK-29397, the Apache Gluten v1.7.0 README, the Apache DataFusion Comet 1.2.0 README and source, and the spark-rapids v26.10.0 configuration docs}}&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;Spark plugin&amp;#039;&amp;#039;&amp;#039; is a class implementing &amp;lt;code&amp;gt;org.apache.spark.api.plugin.SparkPlugin&amp;lt;/code&amp;gt; that [[Apache Spark]] loads into an application at startup, running one component inside the driver and one inside every [[executor]]. Plugins can initialize resources before tasks run, publish custom metrics through Spark&amp;#039;s metrics system, react to task start and end on executors, and send messages from executors to the driver. The API was added in Spark 3.0.0 and is marked as a developer API.&amp;lt;ref name=&amp;quot;sparkplugin&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/java/org/apache/spark/api/plugin/SparkPlugin.java |title=SparkPlugin.java (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-29397 |title=SPARK-29397: Create new plugin interface for driver and executor plugins |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do you load a Spark plugin? ==&lt;br /&gt;
Plugins are loaded by listing their class names in &amp;lt;code&amp;gt;spark.plugins&amp;lt;/code&amp;gt; (since 3.0.0). A second setting, &amp;lt;code&amp;gt;spark.plugins.defaultList&amp;lt;/code&amp;gt;, is prepended to it, so that a platform can put its plugins in the default configuration file and users can still add more on the command line without overwriting them. Duplicate plugins are ignored.&amp;lt;ref name=&amp;quot;coreconf&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/internal/config/package.scala |title=config/package.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;monitoring&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/monitoring.html |title=Monitoring and Instrumentation (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
spark-submit \&lt;br /&gt;
  --jars my-plugin.jar \&lt;br /&gt;
  --conf spark.plugins=com.example.MyPlugin \&lt;br /&gt;
  app.py&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The plugin jar must be on the classpath of both the driver and the executors, because Spark creates one instance in each.&lt;br /&gt;
&lt;br /&gt;
== What are the parts of the plugin API? ==&lt;br /&gt;
A &amp;lt;code&amp;gt;SparkPlugin&amp;lt;/code&amp;gt; returns two optional components. The driver component has a single instance per application, inside the driver; the executor component has one instance in each executor that Spark starts.&amp;lt;ref name=&amp;quot;sparkplugin&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DriverPlugin&amp;#039;&amp;#039;&amp;#039; (since 3.0.0) has these methods:&amp;lt;ref name=&amp;quot;driver&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/java/org/apache/spark/api/plugin/DriverPlugin.java |title=DriverPlugin.java (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;init(SparkContext, PluginContext)&amp;lt;/code&amp;gt; runs early in driver startup, before the task scheduler is initialized, and blocks startup until it returns. The map it returns is passed to every executor plugin&amp;#039;s &amp;lt;code&amp;gt;init&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;registerMetrics(appId, PluginContext)&amp;lt;/code&amp;gt; runs later, once the application ID is known. Metrics added to the context&amp;#039;s registry by then are published as a metrics source named after the plugin.&lt;br /&gt;
* &amp;lt;code&amp;gt;receive(Object)&amp;lt;/code&amp;gt; handles messages sent from executor plugins.&lt;br /&gt;
* &amp;lt;code&amp;gt;shutdown()&amp;lt;/code&amp;gt; runs when the driver stops.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;ExecutorPlugin&amp;#039;&amp;#039;&amp;#039; (since 3.0.0) has these methods:&amp;lt;ref name=&amp;quot;executor&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/java/org/apache/spark/api/plugin/ExecutorPlugin.java |title=ExecutorPlugin.java (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;init(PluginContext, Map&amp;lt;String, String&amp;gt; extraConf)&amp;lt;/code&amp;gt; runs during executor startup and blocks it. Executor metrics must be registered here; metrics registered later may not show up.&lt;br /&gt;
* &amp;lt;code&amp;gt;onTaskStart()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;onTaskSucceeded()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;onTaskFailed(TaskFailedReason)&amp;lt;/code&amp;gt; (all since 3.1.0) run on the task&amp;#039;s own thread. The documentation warns against expensive work here, such as calls to remote services, because they run for every task.&lt;br /&gt;
* &amp;lt;code&amp;gt;shutdown()&amp;lt;/code&amp;gt; runs during executor shutdown and blocks it.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;PluginContext&amp;#039;&amp;#039;&amp;#039; gives both sides a Dropwizard &amp;lt;code&amp;gt;MetricRegistry&amp;lt;/code&amp;gt;, the &amp;lt;code&amp;gt;SparkConf&amp;lt;/code&amp;gt;, the executor ID, the host name and the resources assigned to the process. On executors, &amp;lt;code&amp;gt;send(Object)&amp;lt;/code&amp;gt; sends a message to the driver plugin without waiting, and &amp;lt;code&amp;gt;ask(Object)&amp;lt;/code&amp;gt; waits for a reply, up to &amp;lt;code&amp;gt;spark.rpc.askTimeout&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;context&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/java/org/apache/spark/api/plugin/PluginContext.java |title=PluginContext.java (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example: counting failed tasks per executor ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;scala&amp;quot;&amp;gt;&lt;br /&gt;
package com.example&lt;br /&gt;
&lt;br /&gt;
import java.util.{Collections, Map =&amp;gt; JMap}&lt;br /&gt;
import com.codahale.metrics.Counter&lt;br /&gt;
import org.apache.spark.TaskFailedReason&lt;br /&gt;
import org.apache.spark.api.plugin._&lt;br /&gt;
&lt;br /&gt;
class TaskFailurePlugin extends SparkPlugin {&lt;br /&gt;
  override def driverPlugin(): DriverPlugin = null   // no driver-side component&lt;br /&gt;
&lt;br /&gt;
  override def executorPlugin(): ExecutorPlugin = new ExecutorPlugin {&lt;br /&gt;
    private var failures: Counter = _&lt;br /&gt;
&lt;br /&gt;
    override def init(ctx: PluginContext, extraConf: JMap[String, String]): Unit = {&lt;br /&gt;
      failures = ctx.metricRegistry().counter(&amp;quot;failedTasks&amp;quot;)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    override def onTaskFailed(reason: TaskFailedReason): Unit = failures.inc()&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Loaded with &amp;lt;code&amp;gt;--conf spark.plugins=com.example.TaskFailurePlugin&amp;lt;/code&amp;gt;, the counter appears in each executor&amp;#039;s metrics under the &amp;lt;code&amp;gt;plugin.&amp;lt;Plugin Class Name&amp;gt;&amp;lt;/code&amp;gt; namespace, alongside Spark&amp;#039;s own executor metrics.&amp;lt;ref name=&amp;quot;monitoring&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What is built on the Spark plugin API? ==&lt;br /&gt;
The plugin API is the entry point for several projects that replace or extend Spark&amp;#039;s execution:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;[[Apache Gluten]]&amp;#039;&amp;#039;&amp;#039; offloads compute-intensive SQL processing to native engines such as Velox and ClickHouse while reusing Spark&amp;#039;s control flow. It translates Spark physical plans into Substrait plans and is enabled with &amp;lt;code&amp;gt;spark.plugins=org.apache.gluten.GlutenPlugin&amp;lt;/code&amp;gt;.&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/apache/gluten/blob/v1.7.0/README.md |title=Apache Gluten README (v1.7.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Gluten graduated from the Apache Incubator on 2026-02-18.&amp;lt;ref&amp;gt;{{Cite web |url=https://incubator.apache.org/projects/gluten.html |title=Gluten Project Incubation Status |publisher=Apache Incubator |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;[[DataFusion Comet]]&amp;#039;&amp;#039;&amp;#039; (Apache DataFusion Comet), which describes itself as an accelerator for Apache Spark that runs on commodity hardware, is enabled with &amp;lt;code&amp;gt;spark.plugins=org.apache.spark.CometPlugin&amp;lt;/code&amp;gt;. Its &amp;lt;code&amp;gt;CometPlugin&amp;lt;/code&amp;gt; class implements both a driver and an executor plugin.&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/apache/datafusion-comet/blob/1.2.0/README.md |title=Apache DataFusion Comet README (1.2.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/apache/datafusion-comet/blob/1.2.0/spark/src/main/scala/org/apache/spark/Plugins.scala |title=Plugins.scala (Comet 1.2.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;RAPIDS Accelerator for Apache Spark&amp;#039;&amp;#039;&amp;#039;, from NVIDIA, runs SQL operations on GPUs and is enabled with &amp;lt;code&amp;gt;spark.plugins=com.nvidia.spark.SQLPlugin&amp;lt;/code&amp;gt;.&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/NVIDIA/spark-rapids/blob/v26.10.0/docs/configs.md |title=RAPIDS Accelerator for Apache Spark Configuration (v26.10.0) |publisher=NVIDIA |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Spark plugin vs Spark listener ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! !! Spark plugin !! [[Spark listener]]&lt;br /&gt;
|-&lt;br /&gt;
! Runs on&lt;br /&gt;
| Driver and every executor&amp;lt;ref name=&amp;quot;sparkplugin&amp;quot; /&amp;gt;&lt;br /&gt;
| Driver only, on the listener bus&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/scheduler/LiveListenerBus.scala |title=LiveListenerBus.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Timing&lt;br /&gt;
| Synchronous; &amp;lt;code&amp;gt;init&amp;lt;/code&amp;gt; blocks startup&amp;lt;ref name=&amp;quot;driver&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;executor&amp;quot; /&amp;gt;&lt;br /&gt;
| Asynchronous; events can be dropped if a queue is full&lt;br /&gt;
|-&lt;br /&gt;
! Can publish metrics&lt;br /&gt;
| Yes, through the metrics system&amp;lt;ref name=&amp;quot;context&amp;quot; /&amp;gt;&lt;br /&gt;
| No built-in metrics registry&lt;br /&gt;
|-&lt;br /&gt;
! Configured with&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.plugins&amp;lt;/code&amp;gt;&amp;lt;ref name=&amp;quot;coreconf&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.extraListeners&amp;lt;/code&amp;gt;&amp;lt;ref name=&amp;quot;coreconf&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Typical use&lt;br /&gt;
| Native or GPU execution engines, executor-side instrumentation&lt;br /&gt;
| Lineage, auditing, job monitoring&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Spark listener]]&lt;br /&gt;
* [[Executor]]&lt;br /&gt;
* [[Native execution engine (Spark)]]&lt;br /&gt;
* [[Apache Gluten]]&lt;br /&gt;
* [[DataFusion Comet]]&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>