Skip to main content

ArrayAgg

This class provides the ARRAY_AGG aggregate function, which concatenates input values into an array. It supports both distinct value filtering and custom ordering of the aggregated elements through its internal configuration. The resulting output is automatically wrapped in an array field based on the source expression's type.

Attributes

AttributeTypeDescription
functionstring = ARRAY_AGGThe SQL aggregate function name used for combining multiple values into an array.
allow_distinctboolean = trueA boolean flag indicating that the aggregate supports the DISTINCT keyword to filter for unique values.
allow_order_byboolean = trueA boolean flag indicating that the aggregate supports an ORDER BY clause to determine the sequence of elements in the resulting array.

Methods


output_field()

@classmethod
def output_field() - > [ArrayField](../../fields/array/arrayfield.md?sid=django_contrib_postgres_fields_array_arrayfield)

Determines the resulting data type of the aggregation by wrapping the source expression's field in an ArrayField.

Returns

TypeDescription
[ArrayField](../../fields/array/arrayfield.md?sid=django_contrib_postgres_fields_array_arrayfield)An ArrayField instance that represents a collection of the underlying source expression's data type.