Re: concatenating hstores in a group by?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: concatenating hstores in a group by?
Date: 2025-01-19 16:44:53
Message-ID: 2739254.1737305093@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Friday, January 17, 2025, Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz> wrote:
>> I want to concatenate the hstores,

> There are no hstore aggregate functions.

It would be trivial to make a user-defined one.
More or less (untested)

create aggregate hstore_agg(hstore)
(
sfunc = hs_concat,
stype = hstore
);

Either way though, the order of aggregation is unspecified and thus
it's unclear which input will win when there are duplicate keys.
If that matters then you'll need to think about how you want
to resolve it.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brent Wood 2025-01-19 20:09:48 Re: concatenating hstores in a group by?
Previous Message Adrian Klaver 2025-01-19 16:16:23 Re: concatenating hstores in a group by?