In PostgreSQL 18, a group of three rows holds v values 1, NULL and 2. What do array_agg(v) and string_agg(v::text, ',') return for that group?
Explanation
The two aggregates disagree on purpose: array_agg collects all input values including nulls, so the array has length 3, while string_agg concatenates only the non-null values and emits no separator for the missing one. Assuming both skip nulls is what makes an array and its string rendering fall out of alignment.