raw_to_partial#

TopKUnique.raw_to_partial(block: pyarrow.Table | pandas.DataFrame) → List[AccumulatorType] | pa.Array | pa.ChunkedArray | None#

Optional: turns every row of block into its own accumulator.

With SHUFFLE_V2, a map task normally runs aggregate_block on each group before shuffling. When the group keys are nearly unique, that pass shrinks nothing, so the map task can skip it and ship the rows as they are. The reducer then calls this method to turn those rows into accumulators and merges them with combine. Implementing it lets aggregations skip that pass; see DataContext.partial_aggregation_mode.

Parameters:

block (pyarrow.Table | pandas.DataFrame) – Raw rows: the group key columns and the column this aggregation reads (every column if on is None).

Returns:

the value aggregate_block would return for a block holding only that row (None for a row that contributes nothing, e.g. a null when nulls are ignored). A list, or an Arrow array for speed. None (the default) means the aggregation doesn’t support it, so map tasks always run aggregate_block.

Return type:

One accumulator per row, in row order