Quick revision
The short answer
Kafka Streams supports KStream-KStream joins, which are always windowed, triggered from either side and need co-partitioned inputs; KStream-KTable joins, which are not windowed, triggered only by stream records and need co-partitioning; KStream-GlobalKTable joins, triggered by stream records through a key selector and needing no co-partitioning; KTable-KTable joins on the primary key, triggered by either side and co-partitioned; and KTable-KTable foreign-key joins, which route through internal topics and need no co-partitioning.
What to remember
In this answer, we went through every Kafka Streams join. KStream-KStream joins are always windowed, buffer both sides and trigger from either side. KStream-KTable joins look up the table's current, or versioned, value and trigger only from the stream. KStream-GlobalKTable joins use a key selector and need no co-partitioning. KTable-KTable joins on the primary key trigger from both sides, and foreign-key joins route through internal topics so the tables need not be co-partitioned. Co-partitioning means the same key, partition count and partitioner on both inputs.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Kafka Streams supports KStream-KStream joins, which are always windowed, triggered from either side and need co-partitioned inputs; KStream-KTable joins, which are not windowed, triggered only by stream records and need co-partitioning; KStream-GlobalKTable joins, triggered by stream records through a key selector and needing no co-partitioning; KTable-KTable joins on the primary key, triggered by either side and co-partitioned; and KTable-KTable foreign-key joins, which route through internal topics and need no co-partitioning.
Why this question is asked
Joins are where Kafka Streams differs most from SQL. In a database, a join looks at two tables at one moment; in a stream processor, data keeps arriving on both sides at different times, so each join type has to say what triggers a result and how long anything waits. Interviewers ask for this overview because it reveals whether we can pick the right join for a requirement and predict its behaviour. In this answer, we will recap co-partitioning, then go through each join kind with its window, trigger and partitioning rule, compare them in one table, and note the variants each supports.
1A Quick Recap of Co-Partitioning
Kafka Streams runs a join inside a task, and a task reads the same partition number from each input topic. For two records with the same key to meet, they must be in the same partition number on both sides. That requirement is called co-partitioning: the same key, the same number of partitions, and the same partitioning function on both inputs, so equal keys land in partition i on both and are processed by task i.
Streams can check the partition counts and refuses to start if they differ, but it cannot check that both producers used the same key serialisation and partitioner. A mismatch there produces silently missing join results rather than an error.
2KStream-KStream: Always Windowed
Two streams of events have no notion of current value, so a join between them must say how close in time two records must be to match. That is the JoinWindows, and it is mandatory. Streams buffers both sides in window stores for the window plus grace. A record arriving on either side looks for matches in the other side's buffer and emits a result for each, so both sides trigger. Inputs must be co-partitioned. Inner, left and outer variants exist.
3KStream-KTable: Lookups From the Stream
Here the table holds current state, such as a customer profile, and each stream record looks up the table's value for its key. Only stream records trigger a result; an update to the table changes what future stream records will see, but emits nothing on its own. The join is not windowed. With a regular table store, the lookup sees the table's latest value; with a versioned table store, available in recent versions, it sees the value as of the stream record's timestamp, which makes replays correct. Inputs must be co-partitioned. Inner and left variants exist.
KStream-GlobalKTable is similar, but every instance holds the whole table, so the stream does not need the same key: a key-selector function picks the table key from each stream record, for example the product id inside an order line. No co-partitioning is needed and no repartition happens. Inner and left variants exist, and table updates again trigger nothing.
4KTable-KTable: Primary-Key and Foreign-Key Joins
A join of two tables on their primary key produces another table. An update on either side recomputes the result for that key and emits a table update, so both sides trigger. It is not windowed, the inputs must be co-partitioned, and inner, left and outer variants exist.
The foreign-key join, available since Kafka 2.4, handles the case where the left table's value contains the key of the right table, for example an order table whose value holds a customer id. We pass a function that extracts that foreign key. Streams then sends subscription records through internal topics to the partition that owns each customer and sends responses back, so the two tables need not be co-partitioned, and updates on either side update the result. Inner and left variants exist.
5All Joins Side by Side
Putting the rules in one place makes the choice for a requirement much quicker.
| Join | Windowed? | What triggers a result | Co-partitioned? | Variants |
|---|---|---|---|---|
| KStream-KStream | Yes, JoinWindows | Records on either side | Required | inner, left, outer |
| KStream-KTable | No | Stream records only | Required | inner, left |
| KStream-GlobalKTable | No | Stream records only (key selector) | Not needed | inner, left |
| KTable-KTable (primary key) | No | Updates on either side | Required | inner, left, outer |
| KTable-KTable (foreign key) | No | Updates on either side | Not needed (internal topics) | inner, left |
Notice the pattern: anything joined by partition needs co-partitioning, and the two ways to avoid it are a full copy of the table on every instance (GlobalKTable) or internal routing topics (foreign-key join). Both cost something, memory and startup time in the first case, extra topics and traffic in the second.
6Follow-up questions
Why does a table update not trigger a KStream-KTable join?
Because the join answers the question of what the table said when this event happened. A table change is not an event to be enriched, and if updates triggered results, every profile change would emit a join result for an event that did not happen. If we need results on both sides' changes, we use a KTable-KTable join.
What happens if co-partitioning is broken only by the partitioner?
Streams cannot detect it. Keys hash to different partition numbers on the two topics, so many records find no match and inner joins simply produce fewer results. The fix is to make both producers use the same serializer and partitioner, or to repartition one side inside Streams.
Is there a KTable-GlobalKTable join?
No. GlobalKTables can only be joined from a KStream. To join a table with reference data, use a foreign-key join or a KStream from the table's changes.
7Conclusion
In this answer, we went through every Kafka Streams join. KStream-KStream joins are always windowed, buffer both sides and trigger from either side. KStream-KTable joins look up the table's current, or versioned, value and trigger only from the stream. KStream-GlobalKTable joins use a key selector and need no co-partitioning. KTable-KTable joins on the primary key trigger from both sides, and foreign-key joins route through internal topics so the tables need not be co-partitioned. Co-partitioning means the same key, partition count and partitioner on both inputs.
Open with
There are five kinds. KStream-KStream joins are always windowed with JoinWindows; Streams buffers both sides in window stores, a record from either side produces results for matches inside the window, the inputs must be co-partitioned, and there are inner, left and outer variants.
Then, if they want more
KStream-KTable joins are not windowed; only stream records trigger a lookup of the table's current value, or with a versioned store the value as of the record's timestamp, table updates emit nothing, and the inputs must be co-partitioned.
KStream-GlobalKTable joins are also triggered only by stream records, but they look up through a key-selector function, so the stream does not need re-keying, and there is no co-partitioning requirement because every instance holds the whole table.
KTable-KTable joins on the primary key are not windowed, an update on either side recomputes and emits the result for that key, and they need co-partitioning. The KTable-KTable foreign-key join extracts a foreign key from the left value and matches it to the right table's key; Streams routes data through internal subscription topics, so the tables need not be co-partitioned.
Co-partitioned means the same key, the same partition count and the same partitioner on both inputs, so equal keys are handled by the same task.
About this answer
- Last updated
- 13 November 2026
- Versions it names
- Kafka 2.4
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Kafka documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "List the joins Kafka Streams supports between KStream, KTable and GlobalKTable. For...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-streams-connect/ed79f66d2d/