1

I am trying to join KStream with GlobalKTable, the join is not completely on keys.

GlobalKTable<String, Employee> employeesDetails = builder.globalTable("EMPLOYEE_TOPIC",..);
KStream<String,String> empIdOverLoginUserId = builder.stream("LOG_TOPIC", ….);

I want to join empIdOverLoginUserId with employeesDetails over empIdOverLoginUserId's value over employeesDetails's key.

Any clue?

Venkata Madhu
  • 93
  • 1
  • 14

1 Answers1

2

Second parameter of KStream-GlobalKTable join is a KeyValueMapper to map KStream record (key-value) to the key of GlobalKTable you want to join, you can use this to use empIdOverLoginUserId's value as key when joining with GlobalKTable:

empIdOverLoginUserId.join(
                employeesDetails, 
                (userKey, userValue) -> userValue, 
                (userValue, employeesDetailValue) -> employeesDetailValue)
Tuyen Luong
  • 1,316
  • 8
  • 17
  • 2
    Be aware of: If a `KStream` input record key or value is `null` the record will not be included in the join operation and thus no output record will be added to the resulting `KStream`. If `keyValueMapper` returns `null` implying no match exists, no output record will be added to the resulting `KStream`. – dmkvl Apr 29 '20 at 17:06