Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
    • TableEnvironment
    • Table
    • Data Types
    • Window
    • Expressions
    • User Defined Functions
    • Descriptors
    • StatementSet
    • Catalog
  • PyFlink DataStream
  • PyFlink Common

pyflink.table.Table.aggregate#

Table.aggregate(func: Union[str, pyflink.table.expression.Expression, pyflink.table.udf.UserDefinedAggregateFunctionWrapper]) → pyflink.table.table.AggregatedTable[source]#

Performs a global aggregate operation with an aggregate function. You have to close the aggregate with a select statement.

Example:

>>> agg = udaf(lambda a: (a.mean(), a.max()),
...               result_type=DataTypes.ROW(
...                   [DataTypes.FIELD("a", DataTypes.FLOAT()),
...                    DataTypes.FIELD("b", DataTypes.INT())]),
...               func_type="pandas")
>>> tab.aggregate(agg(col('a')).alias("a", "b")).select(col('a'), col('b'))
>>> # take all the columns as inputs
>>> # pd is a Pandas.DataFrame
>>> agg_row = udaf(lambda pd: (pd.a.mean(), pd.a.max()),
...               result_type=DataTypes.ROW(
...                   [DataTypes.FIELD("a", DataTypes.FLOAT()),
...                    DataTypes.FIELD("b", DataTypes.INT())]),
...               func_type="pandas")
>>> tab.aggregate(agg.alias("a", "b")).select(col("a"), col("b"))
Parameters

func – user-defined aggregate function.

Returns

The result table.

New in version 1.13.0.

previous

pyflink.table.Table.add_or_replace_columns

next

pyflink.table.Table.alias

Show Source

Created using Sphinx 4.5.0.