On Wed, Nov 18, 2020 at 5:37 PM Vik Fearing <v...@postgresfriends.org> wrote:

> On 11/18/20 11:19 PM, David G. Johnston wrote:
> > On Wednesday, November 18, 2020, Vlad Bokov <v...@razum2um.me> wrote:
> >
> >> Hi, I wonder why there's no function to aggregate arrays by
> >> concatenation out of the box?
> >>
> >
> > See array_agg(...)
>
>
> Why?  That doesn't do what is wanted.
>
>
Sorry, I did not read closely enough.

I doubt there is any substantial resistance to including such a function
but it would have to be written in C.


> vik=# select array_agg(a) from (values (array[1]), (array[2])) as v(a);
>  array_agg
> -----------
>  {{1},{2}}
> (1 row)
>

And it's not too hard to work the system to get what you want even without
a custom aggregate.

select array_agg(b) from (values (array[1]), (array[2])) as v(a), unnest(a)
as w(b);

vik=# select array_cat(a) from (values (array[1]), (array[2])) as v(a);
>  array_cat
> -----------
>  {1,2}
> (1 row)
>
>
David J.

Reply via email to