Re: Question about WITH ORDINALITY and unnest - Mailing list pgsql-sql

From Shaozhong SHI
Subject Re: Question about WITH ORDINALITY and unnest
Date
Msg-id CA+i5JwZiY5bdAwTvUoREGkcvA1J=eec4MmbwMncDjS8r0AV0Mw@mail.gmail.com
Whole thread Raw
In response to Re: Question about WITH ORDINALITY and unnest  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Question about WITH ORDINALITY and unnest  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
The most difficult part is unequal numbers of elements in arrays.  For instance, not well structured, delimited addresses.

Has anyone got a nice way to deal with unequal numbers of elements in arrays?

Regards,

David

On Sat, 23 Jan 2021 at 16:14, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Saturday, January 23, 2021, Mike Martin <redtux1@gmail.com> wrote:

Is there any way to make the ordinality ordering to be over the entire record set rather than per array

No
 

(the idea is to combine two arrays of varying dimensions into one, keeping order)

I have got a working solution by adding a rowid and ordering the array by eg: rowid+nr (where rowid is 100,200, big enough not to be in record set)

Yep, this is what I often do as well.

David J.
 

pgsql-sql by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Question about WITH ORDINALITY and unnest
Next
From: Tom Lane
Date:
Subject: Re: Question about WITH ORDINALITY and unnest