pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Create array of data from JSONB in PG 9.5 3+ messages / 3 participants [nested] [flat]
* Create array of data from JSONB in PG 9.5 @ 2019-11-15 10:01 Arup Rakshit <ar@zeit.io> 0 siblings, 2 replies; 3+ messages in thread From: Arup Rakshit @ 2019-11-15 10:01 UTC (permalink / raw) To: pgsql-general@lists.postgresql.org Hi, I wrote the below SQL which works and give me what I want, but it doesn’t work in 9.5 version. I wrote this query in PG 10. I want to change it so that I can run it on 9.5 as production using 9.5 version. I need help on this. SELECT DISTINCT ARRAY [jsonb_array_elements(data) ->> 'group', jsonb_array_elements(jsonb_array_elements(data) -> 'properties') ->> 'name'] FROM "vessels" WHERE "vessels"."deleted_at" IS NULL AND "vessels"."company_id" = '7d105acd-be5a-4225-a2db-b549105e4172'; When I ran the same query to production I get error: ERROR: set-valued function called in context that cannot accept a set Thanks, Arup Rakshit ar@zeit.io ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Create array of data from JSONB in PG 9.5 @ 2019-11-15 15:54 Adrian Klaver <adrian.klaver@aklaver.com> parent: Arup Rakshit <ar@zeit.io> 1 sibling, 0 replies; 3+ messages in thread From: Adrian Klaver @ 2019-11-15 15:54 UTC (permalink / raw) To: Arup Rakshit <ar@zeit.io>; pgsql-general@lists.postgresql.org On 11/15/19 2:01 AM, Arup Rakshit wrote: > Hi, > > I wrote the below SQL which works and give me what I want, but it doesn’t work in 9.5 version. I wrote this query in PG 10. I want to change it so that I can run it on 9.5 as production using 9.5 version. I need help on this. > > SELECT DISTINCT > ARRAY [jsonb_array_elements(data) ->> 'group', jsonb_array_elements(jsonb_array_elements(data) -> 'properties') ->> 'name'] > FROM > "vessels" > WHERE > "vessels"."deleted_at" IS NULL > AND "vessels"."company_id" = '7d105acd-be5a-4225-a2db-b549105e4172'; > > > When I ran the same query to production I get error: > > ERROR: set-valued function called in context that cannot accept a set I would break this down into smaller units to see what is actually triggering the above ERROR. In other words run the jsonb_array_elements() independently and then start adding them together. > > > Thanks, > > Arup Rakshit > ar@zeit.io > > > > > > -- Adrian Klaver adrian.klaver@aklaver.com ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Create array of data from JSONB in PG 9.5 @ 2019-11-15 16:08 Tom Lane <tgl@sss.pgh.pa.us> parent: Arup Rakshit <ar@zeit.io> 1 sibling, 0 replies; 3+ messages in thread From: Tom Lane @ 2019-11-15 16:08 UTC (permalink / raw) To: Arup Rakshit <ar@zeit.io>; +Cc: pgsql-general@lists.postgresql.org Arup Rakshit <ar@zeit.io> writes: > I wrote the below SQL which works and give me what I want, but it doesn’t work in 9.5 version. I wrote this query in PG 10. I want to change it so that I can run it on 9.5 as production using 9.5 version. I need help on this. > SELECT DISTINCT > ARRAY [jsonb_array_elements(data) ->> 'group', jsonb_array_elements(jsonb_array_elements(data) -> 'properties') ->> 'name'] > FROM > "vessels" > WHERE > "vessels"."deleted_at" IS NULL > AND "vessels"."company_id" = '7d105acd-be5a-4225-a2db-b549105e4172'; > When I ran the same query to production I get error: > ERROR: set-valued function called in context that cannot accept a set IIRC, you can't nest calls of set-returning functions before about v10. One workaround is to put the inner set-returning function call into a sub-select. regards, tom lane ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2019-11-15 16:08 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-11-15 10:01 Create array of data from JSONB in PG 9.5 Arup Rakshit <ar@zeit.io> 2019-11-15 15:54 ` Adrian Klaver <adrian.klaver@aklaver.com> 2019-11-15 16:08 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox