Re: proposal: jsonb_populate_array

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: proposal: jsonb_populate_array
Дата
Msg-id CAFj8pRBNMJj=p3Mbk4FLL5FhjhsypV9Tyoc8wKzjO36ynTM3iw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: proposal: jsonb_populate_array  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Ответы Re: proposal: jsonb_populate_array  (Erik Rijkers <er@xs4all.nl>)
Список pgsql-hackers


po 14. 8. 2023 v 11:32 odesílatel Alvaro Herrera <alvherre@alvh.no-ip.org> napsal:
On 2023-Aug-14, Pavel Stehule wrote:

> jsonb_populate_array(anyarray, jsonb) returns anyarray
>
> Usage:
>
> select jsonb_populate_array(null::text[], '["cust_full_name","cust_email"]')

I don't understand what this does.  Can you be more explicit?

example

'["2023-07-13","2023-07-14"]'::jsonb -->  {2023-07-13,2023-07-14}::date[]

Now, I have to transform to table, casting, and back transformation to array, and I cannot to write generic function. I can run just "slow" query

select array_agg(value::date) from jsonb_array_elements_text('["2023-07-13","2023-07-14"]'::jsonb);

with proposed function I can write

select jsonb_populate_array(null:date[], '["2023-07-13","2023-07-14"]'::jsonb)

Regards

Pavel



--
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
Maybe there's lots of data loss but the records of data loss are also lost.
(Lincoln Yeoh)

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

Предыдущее
От: vignesh C
Дата:
Сообщение: Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: Extract numeric filed in JSONB more effectively