<?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_Declarative_Pipelines</id>
	<title>Spark Declarative Pipelines - 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_Declarative_Pipelines"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_Declarative_Pipelines&amp;action=history"/>
	<updated>2026-12-06T00:07:57Z</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_Declarative_Pipelines&amp;diff=50&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@355a38d</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_Declarative_Pipelines&amp;diff=50&amp;oldid=prev"/>
		<updated>2026-11-22T18:53:21Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@355a38d&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox software&lt;br /&gt;
| name                = Spark Declarative Pipelines&lt;br /&gt;
| developer           = [[Apache Software Foundation]] ([[Apache Spark]] project)&lt;br /&gt;
| initial_release     = Spark 4.1.0 (2025-12-16)&lt;br /&gt;
| latest_release      = Spark 4.3.0&lt;br /&gt;
| latest_release_date = 2026-10-30&lt;br /&gt;
| written_in          = Scala, Python&lt;br /&gt;
| type                = Declarative data pipeline framework&lt;br /&gt;
| license             = Apache License 2.0&lt;br /&gt;
| website             = [https://spark.apache.org/docs/latest/declarative-pipelines-programming-guide.html Programming guide]&lt;br /&gt;
| repo                = [https://github.com/apache/spark/tree/v4.3.0/python/pyspark/pipelines github.com/apache/spark (python/pyspark/pipelines)]&lt;br /&gt;
| related             = [[Structured Streaming]], [[Spark Connect]], [[Medallion architecture]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-22|the Spark 4.3.0 Declarative Pipelines programming guide, the pyspark.pipelines and SparkPipelines sources at tag v4.3.0, SPARK-51727, and the Spark 4.1.0, 4.2.0 and 4.3.0 release notes}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Spark Declarative Pipelines&amp;#039;&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;SDP&amp;#039;&amp;#039;&amp;#039;) is a framework in [[Apache Spark]] for building batch and streaming data pipelines by declaring the datasets a pipeline should produce and the queries that fill them, while Spark handles execution order, parallelism, checkpoints and retries.&amp;lt;ref name=&amp;quot;r410&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/releases/spark-release-4.1.0.html |title=Spark Release 4.1.0 |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; SDP was added in Spark 4.1.0.&amp;lt;ref name=&amp;quot;r410&amp;quot; /&amp;gt; Pipelines are written in Python or SQL and run with the &amp;lt;code&amp;gt;spark-pipelines&amp;lt;/code&amp;gt; command line tool.&amp;lt;ref name=&amp;quot;guide&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/declarative-pipelines-programming-guide.html |title=Spark Declarative Pipelines Programming Guide (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Key concepts ==&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;flow&amp;#039;&amp;#039;&amp;#039; reads data from a source, applies processing logic and writes the result into a target dataset. Flows support both streaming and batch semantics. A statement such as &amp;lt;code&amp;gt;CREATE STREAMING TABLE target_table AS SELECT * FROM STREAM source_table&amp;lt;/code&amp;gt; creates both the table and a flow that writes new source data into it.&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;dataset&amp;#039;&amp;#039;&amp;#039; is a queryable object produced by one or more flows. SDP has three kinds of dataset:&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Dataset !! Written by !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Streaming table || One or more streaming flows || A table that processes only new data as it arrives (incremental processing).&lt;br /&gt;
|-&lt;br /&gt;
| Materialized view || Exactly one batch flow || A view whose result is precomputed and stored as a table.&lt;br /&gt;
|-&lt;br /&gt;
| Temporary view || Its defining query || A view scoped to one run of the pipeline, used to share intermediate logic between flows; it cannot be read outside the pipeline.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;pipeline&amp;#039;&amp;#039;&amp;#039; is the unit of development and execution. When a pipeline runs, SDP analyzes the dependencies between its datasets and flows and decides the order of execution and which parts run in parallel.&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;sink&amp;#039;&amp;#039;&amp;#039; lets a pipeline write to a destination outside its own tables, such as Apache Kafka, using any target that a [[Structured Streaming]] query can write to.&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Pipeline spec file ==&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;pipeline project&amp;#039;&amp;#039;&amp;#039; is a set of &amp;lt;code&amp;gt;.py&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.sql&amp;lt;/code&amp;gt; source files plus a YAML spec file, conventionally named &amp;lt;code&amp;gt;spark-pipeline.yml&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;spark-pipeline.yaml&amp;lt;/code&amp;gt;. The spec requires &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;libraries&amp;lt;/code&amp;gt; (paths to the source files) and &amp;lt;code&amp;gt;storage&amp;lt;/code&amp;gt; (a directory for streaming checkpoints). It may also set a default &amp;lt;code&amp;gt;catalog&amp;lt;/code&amp;gt;, a default &amp;lt;code&amp;gt;database&amp;lt;/code&amp;gt; (alias &amp;lt;code&amp;gt;schema&amp;lt;/code&amp;gt;) and a &amp;lt;code&amp;gt;configuration&amp;lt;/code&amp;gt; map of Spark properties.&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt; An example for Spark 4.3:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;yaml&amp;quot;&amp;gt;&lt;br /&gt;
name: my_pipeline&lt;br /&gt;
libraries:&lt;br /&gt;
  - glob:&lt;br /&gt;
      include: transformations/**&lt;br /&gt;
storage: file:///absolute/path/to/storage/dir&lt;br /&gt;
catalog: my_catalog&lt;br /&gt;
database: my_db&lt;br /&gt;
configuration:&lt;br /&gt;
  spark.sql.shuffle.partitions: &amp;quot;1000&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Defining datasets ==&lt;br /&gt;
The Python API lives in the &amp;lt;code&amp;gt;pyspark.pipelines&amp;lt;/code&amp;gt; module, conventionally imported as &amp;lt;code&amp;gt;dp&amp;lt;/code&amp;gt;. In Spark 4.3 it exports &amp;lt;code&amp;gt;materialized_view&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;table&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;temporary_view&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;append_flow&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;create_streaming_table&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;create_auto_cdc_flow&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;create_sink&amp;lt;/code&amp;gt;.&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/python/pyspark/pipelines/__init__.py |title=pyspark/pipelines/__init__.py (tag v4.3.0) |publisher=Apache Spark on GitHub |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; A function decorated with &amp;lt;code&amp;gt;@dp.materialized_view&amp;lt;/code&amp;gt; that returns a batch DataFrame defines a materialized view; one decorated with &amp;lt;code&amp;gt;@dp.table&amp;lt;/code&amp;gt; that returns a streaming DataFrame defines a streaming table. The dataset takes the function&amp;#039;s name unless a &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; argument is given.&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since Spark 4.2, SDP injects the &amp;lt;code&amp;gt;spark&amp;lt;/code&amp;gt; session into each pipeline file, so the file does not need to create one. In Spark 4.1 each file had to assign &amp;lt;code&amp;gt;spark = SparkSession.active()&amp;lt;/code&amp;gt; itself.&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pyspark import pipelines as dp&lt;br /&gt;
from pyspark.sql import DataFrame&lt;br /&gt;
&lt;br /&gt;
@dp.table&lt;br /&gt;
def raw_orders() -&amp;gt; DataFrame:&lt;br /&gt;
    return spark.readStream.table(&amp;quot;orders_source&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@dp.materialized_view&lt;br /&gt;
def orders_by_state() -&amp;gt; DataFrame:&lt;br /&gt;
    return spark.table(&amp;quot;raw_orders&amp;quot;).groupBy(&amp;quot;state&amp;quot;).count()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The same datasets can be declared in SQL with &amp;lt;code&amp;gt;CREATE STREAMING TABLE ... AS SELECT ... FROM STREAM ...&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CREATE MATERIALIZED VIEW&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CREATE TEMPORARY VIEW&amp;lt;/code&amp;gt;. Several flows can append to one streaming table with &amp;lt;code&amp;gt;@dp.append_flow&amp;lt;/code&amp;gt; in Python or &amp;lt;code&amp;gt;CREATE FLOW&amp;lt;/code&amp;gt; in SQL.&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The spark-pipelines CLI ==&lt;br /&gt;
The &amp;lt;code&amp;gt;spark-pipelines&amp;lt;/code&amp;gt; CLI is built on &amp;lt;code&amp;gt;spark-submit&amp;lt;/code&amp;gt; and accepts all of its arguments except &amp;lt;code&amp;gt;--class&amp;lt;/code&amp;gt;, so it works with every cluster manager that &amp;lt;code&amp;gt;spark-submit&amp;lt;/code&amp;gt; supports.&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt; It has three commands:&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;spark-pipelines init --name my_pipeline&amp;lt;/code&amp;gt; creates a new project directory with a spec file and example definitions.&lt;br /&gt;
* &amp;lt;code&amp;gt;spark-pipelines run&amp;lt;/code&amp;gt; runs the pipeline and monitors it until it completes. Options include &amp;lt;code&amp;gt;--spec&amp;lt;/code&amp;gt; (path to the spec file), &amp;lt;code&amp;gt;--refresh&amp;lt;/code&amp;gt; (update listed datasets), &amp;lt;code&amp;gt;--full-refresh&amp;lt;/code&amp;gt; (clear and recompute listed datasets, including their checkpoints) and &amp;lt;code&amp;gt;--full-refresh-all&amp;lt;/code&amp;gt;. Without these options, the run is an incremental update.&lt;br /&gt;
* &amp;lt;code&amp;gt;spark-pipelines dry-run&amp;lt;/code&amp;gt; builds and checks the pipeline without reading or writing any data.&lt;br /&gt;
&lt;br /&gt;
In Spark 4.3, the launcher always runs the pipeline in Spark Connect mode: it sets &amp;lt;code&amp;gt;spark.api.mode=connect&amp;lt;/code&amp;gt; and fails if a user passes any other value.&amp;lt;ref&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/deploy/SparkPipelines.scala |title=SparkPipelines.scala (tag v4.3.0) |publisher=Apache Spark on GitHub |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; A run can target a remote [[Spark Connect]] server with &amp;lt;code&amp;gt;--remote sc://host:15002&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Dry runs ===&lt;br /&gt;
A dry run catches many errors that would otherwise appear only during a real run: syntax errors in Python or SQL code, analysis errors such as a reference to a table or column that does not exist, and graph validation errors such as cyclic dependencies between datasets.&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt; Because it reads and writes no data, a dry run can check a pipeline before it uses compute on real data.&lt;br /&gt;
&lt;br /&gt;
== Change data capture ==&lt;br /&gt;
Spark 4.2.0 added &amp;#039;&amp;#039;&amp;#039;Auto CDC&amp;#039;&amp;#039;&amp;#039; to SDP, which applies a stream of insert, update and delete events to a target streaming table as Slowly Changing Dimension (SCD) Type 1 upserts.&amp;lt;ref&amp;gt;{{Cite web |url=https://spark.apache.org/releases/spark-release-4-2-0.html |title=Spark Release 4.2.0 |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; Spark 4.3.0 added SCD Type 2, which keeps the history of how each record changed.&amp;lt;ref name=&amp;quot;r430&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/releases/spark-release-4-3-0.html |title=Spark Release 4.3.0 |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; An Auto CDC flow needs key columns and a sequencing expression, and its target must be a streaming table backed by a format that supports row-level operations (MERGE); Spark&amp;#039;s built-in file formats, including Parquet, do not qualify.&amp;lt;ref name=&amp;quot;guide&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
SDP was proposed in the Spark Project Improvement Proposal tracked as SPARK-51727, opened in April 2025 and resolved with fix version 4.1.0.&amp;lt;ref&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-51727 |title=SPARK-51727: SPIP: Declarative Pipelines |publisher=Apache Software Foundation JIRA |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; On 11 June 2025, Databricks announced that it would contribute its declarative ETL framework to Apache Spark as Spark Declarative Pipelines.&amp;lt;ref&amp;gt;{{Cite web |url=https://www.databricks.com/company/newsroom/press-releases/databricks-donates-declarative-pipelines-apache-sparktm-open-source |title=Databricks Donates Declarative Pipelines to Apache Spark Open Source Project |publisher=Databricks |date=2025-06-11 |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; A Databricks blog post from the next day traces that framework to Databricks&amp;#039; DLT product.&amp;lt;ref&amp;gt;{{Cite web |url=https://www.databricks.com/blog/bringing-declarative-pipelines-apache-spark-open-source-project |title=Bringing Declarative Pipelines to the Apache Spark Open Source Project |publisher=Databricks |date=2025-06-12 |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; Databricks documentation states that its Lakeflow pipelines product is built on SDP.&amp;lt;ref&amp;gt;{{Cite web |url=https://docs.databricks.com/aws/en/ldp/concepts/spark-declarative-pipelines |title=Spark Declarative Pipelines |publisher=Databricks documentation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Use in an open lakehouse ==&lt;br /&gt;
SDP writes its datasets through Spark&amp;#039;s catalogs, so the spec&amp;#039;s &amp;lt;code&amp;gt;catalog&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;database&amp;lt;/code&amp;gt; fields can point at a catalog such as an [[Iceberg REST catalog]] or [[Unity Catalog]]. A pipeline of streaming tables feeding materialized views maps onto the bronze, silver and gold layers of a [[medallion architecture]]. An orchestrator such as [[Apache Airflow]] can run &amp;lt;code&amp;gt;spark-pipelines&amp;lt;/code&amp;gt; as one task in a larger workflow.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Apache Spark]]&lt;br /&gt;
* [[Structured Streaming]]&lt;br /&gt;
* [[Spark Connect]]&lt;br /&gt;
* [[Medallion architecture]]&lt;br /&gt;
* [[Apache Airflow]]&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:Pipelines and orchestration]]&lt;br /&gt;
[[Category:Apache Spark]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>