Skip to main content
Ctrl+K
PyFlink 1.20+vvr.11.7.dev0 documentation - Home PyFlink 1.20+vvr.11.7.dev0 documentation - Home
  • API Reference
  • Examples
  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
  • PyFlink DataStream
    • StreamExecutionEnvironment
    • DataStream
    • Functions
    • State
    • Timer
    • Window
    • Checkpoint
    • Side Outputs
    • Asynchronous I/O
    • Connectors
    • Formats
  • PyFlink DataFrame
  • PyFlink Common
  • API Reference
  • PyFlink DataStream
  • DataStream
  • pyflink.datastream.data_stream.KeyedStream.reduce

pyflink.datastream.data_stream.KeyedStream.reduce#

KeyedStream.reduce(func: Callable | ReduceFunction) → DataStream[source]#

Applies a reduce transformation on the grouped data stream grouped on by the given key position. The ReduceFunction will receive input values based on the key value. Only input values with the same key will go to the same reducer.

Example:

>>> ds = env.from_collection([(1, 'a'), (2, 'a'), (3, 'a'), (4, 'b'])
>>> ds.key_by(lambda x: x[1]).reduce(lambda a, b: a[0] + b[0], b[1])
Parameters:

func – The ReduceFunction that is called for each element of the DataStream.

Returns:

The transformed DataStream.

previous

pyflink.datastream.data_stream.KeyedStream.flat_map

next

pyflink.datastream.data_stream.KeyedStream.filter

On this page
  • KeyedStream.reduce()

This Page

  • Show Source

Created using Sphinx 7.4.7.

Built with the PyData Sphinx Theme 0.16.1.