From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Vik Fearing <vik(at)postgresfriends(dot)org> |
Cc: | Vlad Bokov <vlad(at)razum2um(dot)me>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: CREATE AGGREGATE array_cat |
Date: | 2020-11-19 00:46:52 |
Message-ID: | CAKFQuwY-fZ3STg5GB1Rc7MMDnwp-LHgo97MPWUzAVJD4WObQ+w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Nov 18, 2020 at 5:37 PM Vik Fearing <vik(at)postgresfriends(dot)org> wrote:
> On 11/18/20 11:19 PM, David G. Johnston wrote:
> > On Wednesday, November 18, 2020, Vlad Bokov <vlad(at)razum2um(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Vik Fearing | 2020-11-19 00:53:48 | Re: pl/pgsql feature request: shorthand for argument and local variable references |
Previous Message | Vik Fearing | 2020-11-19 00:37:26 | Re: CREATE AGGREGATE array_cat |