pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Guyren Howe <guyren@gmail.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: How to unnest nested arrays
Date: Mon, 6 Apr 2020 18:11:49 -0700
Message-ID: <9BFD1A82-0B06-4B57-A5F4-8525E122B12B@gmail.com> (raw)

Consider this:

select (array[array[1, 2], array[3, 4]])[i:i]
from generate_subscripts(array[array[1, 2], array[3, 4]], 1) i

which produces:

{{1,2}}
{{3,4}}

I expect and want, from that source:

{1, 2}
{3, 4}

These don’t work:

select (array[array[1, 2], array[3, 4]])[i:i][:]
{{1,2}}
{{3,4}}

select (array[array[1, 2], array[3, 4]])[i:i][1:1]
{{1}}
{{3}}


Also: could we _please_ get a version of unnest that doesn’t explode any number of dimensions into 1?

view thread (5+ messages)  latest in thread

Message-ID: <9BFD1A82-0B06-4B57-A5F4-8525E122B12B@gmail.com>
Permalink:  ../9BFD1A82-0B06-4B57-A5F4-8525E122B12B@gmail.com/
Also on:    postgresql.org/message-id/9BFD1A82-0B06-4B57-A5F4-8525E122B12B@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: guyren@gmail.com
  Subject: Re: How to unnest nested arrays
  In-Reply-To: <9BFD1A82-0B06-4B57-A5F4-8525E122B12B@gmail.com>
  References: <9BFD1A82-0B06-4B57-A5F4-8525E122B12B@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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