partitioned_agg_by

partitioned_agg_by is a convenience method that performs an agg_by operation on the source table and wraps the result in a PartitionedTable.

Note

If the argument aggs does not include a partition aggregation created by calling agg.partition(), one will be added automatically with the default constituent column name __CONSTITUENT__.

Syntax

Parameters

ParameterTypeDescription
aggsUnion[Aggregation, Sequence[Aggregagation]]

The aggregation(s) to apply to the source table.

by optionalUnion[str, Sequence[str]]

The group by column name(s). The default is None.

preserve_empty optionalbool

Whether to keep result rows for groups that are initially empty, or become empty as a result of updates. Each aggregation operator defines its own value for empty groups. The default is False.

initial_groups optionalTable

A table whose distinct combinations of values for the group by column(s) should be used to create an initial set of aggregation groups. All other columns are ignored.

  • In combination with preserve_empty=True, this ensures that particular groups appear in the result table.
  • With preserve_empty=False, use this table to control the encounter order for a collection of groups, and thus their relative order in the result.
  • Default is None, which will produce a result that is the same as if a table is provided but no rows were supplied.

When a table is provided, the by argument must also be provided to explicitly specify the grouping columns.

Note: Changes to this table are not expected or handled; if this table is a refreshing table, only its contents at instantiation time will be used.

Returns

A PartitionedTable.

Examples

In this example, partitioned_agg_by returns the source table, as partitioned by StreetName. The partitioned table is identical to the source table, so the constituent_tables method is invoked to demonstrate that the table has been partitioned.