Kafka Streams FK-join within the same KTable

Posted on
til kafka-streams streaming-joins dev

KTable to KTable foreign-key joins is one of the coolest features in Kafka Streams.

I was wondering whether this feature would handle FK-joins between values on the same table.

Seems that the answer is yes:

var ktable = builder.table("table", Consumed.with(Serdes.String(), Serdes.String()));
    .join(ktable, s -> s, (v1, v2) -> v1 + "-" + v2)
    .to("fkjoin_v1", Produced.with(Serdes.String(), Serdes.String()));

Values will be used as keys. With the following inputs:


The following output is expected:


For reference this is the topology graph:

Kafka Streams topology