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.FlatAggregateTable.select#

FlatAggregateTable.select(*fields: Union[str, pyflink.table.expression.Expression]) → pyflink.table.table.Table[source]#

Performs a selection operation on a FlatAggregateTable. Similar to a SQL SELECT statement. The field expressions can contain complex expressions.

Example:

>>> table_agg = udtaf(MyTableAggregateFunction())
>>> tab.flat_aggregate(table_agg(col('a')).alias("a", "b")).select(col('a'), col('b'))
>>> # take all the columns as inputs
>>> class Top2(TableAggregateFunction):
...     def emit_value(self, accumulator):
...         yield Row(accumulator[0])
...         yield Row(accumulator[1])
...
...     def create_accumulator(self):
...         return [None, None]
...
...     def accumulate(self, accumulator, *args):
...         args[0] # type: Row
...         if args[0][0] is not None:
...             if accumulator[0] is None or args[0][0] > accumulator[0]:
...                 accumulator[1] = accumulator[0]
...                 accumulator[0] = args[0][0]
...             elif accumulator[1] is None or args[0][0] > accumulator[1]:
...                 accumulator[1] = args[0][0]
...
...     def get_accumulator_type(self):
...         return DataTypes.ARRAY(DataTypes.BIGINT())
...
...     def get_result_type(self):
...         return DataTypes.ROW(
...             [DataTypes.FIELD("a", DataTypes.BIGINT())])
>>> top2 = udtaf(Top2())
>>> tab.group_by(col('c')) \
...    .flat_aggregate(top2.alias("a", "b")) \
...    .select(col('a'), col('b'))
Parameters

fields – Expression string.

Returns

The result table.

previous

pyflink.table.table.AggregatedTable.select

next

Data Types

Show Source

Created using Sphinx 4.5.0.