Kafka Streams - Joining Stream record on KTable with multiple fields

Viewed 329

This is probably a silly question but I wonder if it's possible to join a KStream on two fields with a KTable/GlobalKTable? For example let's say I have this object that's the value of the records in the KStream.

{"gameId": 1, "awayTeamId": 1, "homeTeamId": 2}

I will have a KTable/Topic that looks like this -

{"teamId": 1, "teamName": "Team 1", "teamId": 2, "teamName": "Team 2"}

I want to join both the awayTeamId and homeTeamId with a KTable so that I can enrich the message so that the resulting record will look something like this...

{"gameId": 1, "awayTeamId": 1, "awayTeamName": "Team 1", "homeTeamId": 2, "homeTeamName": "Team 2"}

I'm guessing you could maybe have a branch with one branch handling the awayTeam join and another branch handling the homeTeam join and maybe end up creating an entirely new record with a map or mapValues call and maybe combining the two separate branches? I'm not sure if this is a viable method or if there are other avenues to pursue.

0 Answers
Related