Side outputs for identical outputs Hi! Does anyon...
# random
k
Side outputs for identical outputs Hi! Does anyone know if this works as expected in Flink 1.13?
Copy code
val events = ... # Define data stream
val stream1 = events.process(...)
val stream2 = events.process(...)
The docs for side outputs says that "_[side outputs are] useful when you want to split a stream of data where you would normally have to replicate the stream_". I don't understand if side outputs are necessary if I just want to process the same stream with two different operators. Thanks for any comments!
n
we use side ouputs in 1.16, but the implementation is quite different to what you have there. Do you want to have multiple sinks?
k
Hi! Yes, the results from both "stream1" and "stream2" go to different sinks.
n
I can show you how we do it - hope it helps with your version
k
Thanks! I don't have any problem making it run, we can implement it with side outputs and it works fine. Just curious if side outputs are even needed in this case.
n
ah. I found no way at all to write to multiple sinks without side outputs. But I hear there are other ways. This is the recommended one afaik
👍 1
d
If you want to fork a stream, sending all of the events down multiple paths, then the code you outlined is the perfect way to do it:
Copy code
val events = ... # Define data stream
val stream1 = events.process(...)
val stream2 = events.process(...)
But if you want to split a stream, so that some events take one path and others take other paths, then you can either fork the stream as shown and then apply different filters to it:
Copy code
val events = ... # Define data stream
val substream1 = events.filter1(...)
val substream2 = events.filter2(...)
Or you can use side outputs. One big advantage of side outputs is that the various output streams can have different types.
k
Thanks so much, it's very clear now 🙏