Re: Proposal: array_unique_agg() function

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Proposal: array_unique_agg() function
Дата
Msg-id CAFj8pRAyNnojDUR=jbED=DoXMMJkOwKPXZVmy_qMLejCSy8GWw@mail.gmail.com
обсуждение исходный текст
Ответ на Proposal: array_unique_agg() function  (Aleksander Alekseev <aleksander@timescale.com>)
Список pgsql-hackers
Hi

út 1. 3. 2022 v 14:39 odesílatel Aleksander Alekseev <aleksander@timescale.com> napsal:
Hi hackers,

I needed an aggregate function similar to array_agg() but which
aggregates only unique values. As it turned out there is no convenient
way of doing this. What I ended up doing instead was aggregating to
JSONB keys and then converting a JSONB object to an array:

SELECT array(select jsonb_object_keys(jsonb_object_agg(mycolumn, true)))
FROM ...

This works but doesn't seem to be the greatest user experience. I
would like to submit a patch that adds array_unique_agg() function
unless anyone has strong objections to this feature.

SELECT array_agg(DISTINCT ...) doesn't help?

Regards

Pavel
 

--
Best regards,
Aleksander Alekseev


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Aleksander Alekseev
Дата:
Сообщение: Proposal: array_unique_agg() function
Следующее
От: Sergei Kornilov
Дата:
Сообщение: Re:Proposal: array_unique_agg() function