<?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=Stream-static_join</id>
	<title>Stream-static join - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Stream-static_join"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Stream-static_join&amp;action=history"/>
	<updated>2026-12-06T00:25:17Z</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=Stream-static_join&amp;diff=210&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=Stream-static_join&amp;diff=210&amp;oldid=prev"/>
		<updated>2026-11-25T00:53:01Z</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            = Stream-static join&lt;br /&gt;
| also_known_as   = Stream-table join, stream enrichment join&lt;br /&gt;
| field           = [[Stream processing]]&lt;br /&gt;
| introduced      = Apache Spark 2.0&lt;br /&gt;
| key_parts       = A streaming DataFrame, a static (batch) DataFrame or table, join keys; no streaming state&lt;br /&gt;
| implementations = [[Structured Streaming]] in [[Apache Spark]]; related forms in [[Apache Flink]] SQL (temporal and lookup joins)&lt;br /&gt;
| related         = [[Stream-stream join]], [[Delta Lake]], [[Broadcast join]], [[Stateful stream processing]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the Spark 4.3.0 Structured Streaming programming guide (join operations, support matrix) and Real-time Mode guide, the Databricks &amp;quot;Work with joins&amp;quot; page, and the Apache Flink 2.3 SQL &amp;quot;Joins&amp;quot; page}}&lt;br /&gt;
&lt;br /&gt;
In [[Apache Spark]] [[Structured Streaming]], a &amp;#039;&amp;#039;&amp;#039;stream-static join&amp;#039;&amp;#039;&amp;#039; joins a streaming DataFrame with a static DataFrame, for example a stream of orders with a table of customers. Each micro-batch of the stream is joined with the static side, and the join keeps no streaming state, so it needs no [[watermark]]. Structured Streaming has supported stream-static joins, inner and some outer types, since Spark 2.0.&amp;lt;ref name=&amp;quot;ss-ss&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/streaming/apis-on-dataframes-and-datasets.html#stream-static-joins |title=Structured Streaming: Stream-static Joins (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; It is the usual way to enrich events with reference or dimension data held in a lakehouse table.&lt;br /&gt;
&lt;br /&gt;
== How does a stream-static join work? ==&lt;br /&gt;
The static side is an ordinary batch DataFrame read with &amp;lt;code&amp;gt;spark.read&amp;lt;/code&amp;gt;, and the streaming side comes from &amp;lt;code&amp;gt;spark.readStream&amp;lt;/code&amp;gt;. The join is written like a batch join:&amp;lt;ref name=&amp;quot;ss-ss&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
customers = spark.read.table(&amp;quot;main.crm.customers&amp;quot;)          # static side&lt;br /&gt;
orders = spark.readStream.table(&amp;quot;main.sales.orders&amp;quot;)       # streaming side&lt;br /&gt;
&lt;br /&gt;
enriched = orders.join(customers, &amp;quot;customer_id&amp;quot;, &amp;quot;left_outer&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
(enriched.writeStream&lt;br /&gt;
    .option(&amp;quot;checkpointLocation&amp;quot;, &amp;quot;/checkpoints/orders_enriched&amp;quot;)&lt;br /&gt;
    .toTable(&amp;quot;main.sales.orders_enriched&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because only the streaming side changes, each batch&amp;#039;s new rows are joined with the static data and the result is final; nothing is buffered for later matches. The Spark guide states that stream-static joins are not stateful and need no state management.&amp;lt;ref name=&amp;quot;ss-ss&amp;quot; /&amp;gt; This is the main difference from a [[stream-stream join]], which buffers both inputs.&lt;br /&gt;
&lt;br /&gt;
== Which join types are supported? ==&lt;br /&gt;
The support matrix in Spark 4.3.0 allows only the join types in which the streaming side&amp;#039;s rows can be completed from the static side alone:&amp;lt;ref name=&amp;quot;ss-matrix&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/streaming/apis-on-dataframes-and-datasets.html#support-matrix-for-joins-in-streaming-queries |title=Structured Streaming: Support matrix for joins in streaming queries (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Left input !! Right input !! Inner !! Left outer !! Right outer !! Full outer !! Left semi&lt;br /&gt;
|-&lt;br /&gt;
| Stream || Static || Yes || Yes || No || No || Yes&lt;br /&gt;
|-&lt;br /&gt;
| Static || Stream || Yes || No || Yes || No || No&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The unsupported types would need to emit a static row once it is clear that no streaming row will ever match it, which cannot be known for an unbounded stream without state.&lt;br /&gt;
&lt;br /&gt;
== How is the static side refreshed? ==&lt;br /&gt;
The Databricks documentation, for a static side stored in [[Delta Lake]], states that each micro-batch joins the latest valid version of the static Delta table with the records of that micro-batch. The static table should therefore change slowly. If it changes between runs, reprocessing the same streaming data can give different results, so the output is not deterministic while the static side is changing.&amp;lt;ref name=&amp;quot;db-join&amp;quot;&amp;gt;{{Cite web |url=https://docs.databricks.com/aws/en/transform/join |title=Work with joins on Databricks |publisher=Databricks |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rows already written are not revised when the static side changes later. An order joined with a customer&amp;#039;s old address keeps the old address in the output, because the join keeps no state with which to revisit it.&amp;lt;ref name=&amp;quot;ss-ss&amp;quot; /&amp;gt; Pipelines that need updates on both sides use a [[stream-stream join]] or a materialized view instead; Databricks recommends a materialized view for incremental results of an inner join.&amp;lt;ref name=&amp;quot;db-join&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Stream-static joins in Real-time Mode ==&lt;br /&gt;
Real-time Mode, added in Spark 4.1.0, supports stream-static joins only when the static side is broadcast with the &amp;lt;code&amp;gt;broadcast(...)&amp;lt;/code&amp;gt; hint, because the join must not add a shuffle.&amp;lt;ref name=&amp;quot;rtm&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/streaming/real-time-mode.html |title=Real-time Mode (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;python&amp;quot;&amp;gt;&lt;br /&gt;
from pyspark.sql.functions import broadcast&lt;br /&gt;
&lt;br /&gt;
enriched = orders.join(broadcast(customers), &amp;quot;customer_id&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In micro-batch mode the hint is optional and follows the usual [[join strategy hints|join strategy]] rules.&lt;br /&gt;
&lt;br /&gt;
== Stream-static join vs stream-stream join ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! !! Stream-static join !! Stream-stream join&lt;br /&gt;
|-&lt;br /&gt;
! Inputs&lt;br /&gt;
| One streaming, one batch DataFrame&amp;lt;ref name=&amp;quot;ss-ss&amp;quot; /&amp;gt;&lt;br /&gt;
| Two streaming DataFrames&amp;lt;ref name=&amp;quot;ss-sts&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/streaming/apis-on-dataframes-and-datasets.html#stream-stream-joins |title=Structured Streaming: Stream-stream Joins (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! State&lt;br /&gt;
| None&amp;lt;ref name=&amp;quot;ss-ss&amp;quot; /&amp;gt;&lt;br /&gt;
| Both inputs buffered in the state store&amp;lt;ref name=&amp;quot;ss-sts&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Watermark&lt;br /&gt;
| Not needed&amp;lt;ref name=&amp;quot;db-join&amp;quot; /&amp;gt;&lt;br /&gt;
| Needed to bound state; required for outer and semi joins&amp;lt;ref name=&amp;quot;ss-sts&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Since&lt;br /&gt;
| Spark 2.0&amp;lt;ref name=&amp;quot;ss-ss&amp;quot; /&amp;gt;&lt;br /&gt;
| Spark 2.3&amp;lt;ref name=&amp;quot;ss-sts&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Real-time Mode (Spark 4.3.0)&lt;br /&gt;
| Supported with a broadcast static side&amp;lt;ref name=&amp;quot;rtm&amp;quot; /&amp;gt;&lt;br /&gt;
| Not supported&amp;lt;ref name=&amp;quot;rtm&amp;quot; /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Comparison with Flink ==&lt;br /&gt;
[[Apache Flink]] SQL has two related joins. A &amp;#039;&amp;#039;&amp;#039;temporal join&amp;#039;&amp;#039;&amp;#039; joins against a versioned table, so that each row can be matched with the version valid at its event time. A &amp;#039;&amp;#039;&amp;#039;lookup join&amp;#039;&amp;#039;&amp;#039; enriches a table with data queried from an external system; one side needs a processing-time attribute and the other must be backed by a lookup source connector.&amp;lt;ref name=&amp;quot;flink-join&amp;quot;&amp;gt;{{Cite web |url=https://nightlies.apache.org/flink/flink-docs-release-2.3/docs/sql/reference/queries/joins/ |title=Joins (Apache Flink 2.3) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; A Spark stream-static join against a Delta table is closest to a processing-time lookup: each batch sees the table as it is when the batch runs.&amp;lt;ref name=&amp;quot;db-join&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Stream-stream join]]&lt;br /&gt;
* [[Broadcast join]]&lt;br /&gt;
* [[Delta Lake]]&lt;br /&gt;
* [[Structured Streaming]]&lt;br /&gt;
* [[Medallion architecture]]&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:Pipelines and orchestration]]&lt;br /&gt;
[[Category:Apache Spark]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>