Apache Flink: What's the difference between side outputs and split() in the DataStream API?
The split
operator is part of the DataStream API since its early days. The side output feature as added later and offers a superset of split
's functionality.
split
creates multiple streams of the same type, the input type. Side outputs can be of any type, i.e., also different from the input and the main output.
Internally, split
adds dedicated operator that just splits the stream. Side outputs are defined within an operator (typically a ProcessFunction
or window operator) that apply arbitrary logic and feature multiple outputs. I would not expect this to result in a significant performance difference.
A common use case for side outputs is to filter out invalid (or late) records and pass them unmodified to the side, e.g., to process them later. Such an operator has a regular output with the desired result type and a side output with its input type. This logic would be cumbersome to implement using split
.