pyflink.datastream.data_stream.CachedDataStream.broadcast#
- CachedDataStream.broadcast(broadcast_state_descriptor: Optional[MapStateDescriptor] = None, *other_broadcast_state_descriptors: MapStateDescriptor) Union[DataStream, BroadcastStream]#
Sets the partitioning of the DataStream so that the output elements are broadcasted to every parallel instance of the next operation.
If
MapStateDescriptors are passed in, it returns aBroadcastStreamwithBroadcastStates implicitly created as the descriptors specified.Example:
>>> map_state_desc1 = MapStateDescriptor("state1", Types.INT(), Types.INT()) >>> map_state_desc2 = MapStateDescriptor("state2", Types.INT(), Types.STRING()) >>> broadcast_stream = ds1.broadcast(map_state_desc1, map_state_desc2) >>> broadcast_connected_stream = ds2.connect(broadcast_stream)
- Parameters
broadcast_state_descriptor – the first MapStateDescriptor describing BroadcastState.
other_broadcast_state_descriptors – the rest of MapStateDescriptors describing BroadcastStates, if any.
- Returns
The DataStream with broadcast partitioning set or a BroadcastStream which can be used in
connect()to create a BroadcastConnectedStream for further processing of the elements.
Changed in version 1.16.0: Support return BroadcastStream