pyflink.datastream.data_stream.KeyedStream.min#
- KeyedStream.min(position_to_min: Union[int, str] = 0) pyflink.datastream.data_stream.DataStream [source]#
Applies an aggregation that gives the current minimum of the data stream at the given position by the given key. An independent aggregate is kept per key.
Example(Tuple data):
>>> ds = env.from_collection([('a', 1), ('a', 2), ('b', 1), ('b', 5)]) >>> ds.key_by(lambda x: x[0]).min(1)
Example(Row data):
>>> ds = env.from_collection([('a', 1), ('a', 2), ('a', 3), ('b', 1), ('b', 2)], ... type_info=Types.ROW([Types.STRING(), Types.INT()])) >>> ds.key_by(lambda x: x[0]).min(1)
Example(Row data with fields name):
>>> ds = env.from_collection( ... [('a', 1), ('a', 2), ('a', 3), ('b', 1), ('b', 2)], ... type_info=Types.ROW_NAMED(["key", "value"], [Types.STRING(), Types.INT()]) ... ) >>> ds.key_by(lambda x: x[0]).min("value")
- Parameters
position_to_min – The field position in the data points to minimize. The type can be int (field position) or str (field name). This is applicable to Tuple types, List types, Row types, and basic types (which is considered as having one field).
- Returns
The transformed DataStream.
New in version 1.16.0.