Search code examples
sessionjoinstreamapache-flink

Flink Join two streams inside a session window


I have two streams and want join second stream to first inside a window because I need to do some computation on the join of the two streams related to a session (on of the streams governs the session).

Actually, as read from the documentation, the (session) window allows computations only on a single stream not in a join.

I have tried to use a combination of session window and coprocessor function but the result is not exactly what I expected.

Is there a way to merge two streams related to a session window in Flink?


Solution

  • Flink's DataStream API includes a session window join, which is described here.

    You'll have to see if its semantics match what you have in mind. The session gap is defined by both streams having no events during that interval, and the join is an inner join, so if there is a session window that only contains elements from one stream, no output will be emitted.

    If that doesn't meet your needs, then I would suggest a CoProcessFunction, but without a session window. In other words, I'm suggesting you might implement all of the logic yourself.