Re: array UNNESTed to rows stable with respect to order? - Mailing list pgsql-general

From David G. Johnston
Subject Re: array UNNESTed to rows stable with respect to order?
Date
Msg-id CAKFQuwYNER-h8qRN33+CLTfP0k8oYhTZhaTig=Gt3Oez2bHJWA@mail.gmail.com
Whole thread Raw
In response to array UNNESTed to rows stable with respect to order?  (Thiemo Kellner <thiemo@gelassene-pferde.biz>)
Responses Re: array UNNESTed to rows stable with respect to order?
List pgsql-general
On Tue, Apr 17, 2018 at 1:20 PM, Thiemo Kellner <thiemo@gelassene-pferde.biz> wrote:
This works fine but I am not sure whether the ordering remains in the later use.

​It does not.  If the array is not naturally ordered you will want to attach a "with ordinality" clause to it for performing future ordering.

select * from unnest(ARRAY[3,6,4]::integer[]) with ordinality

Use LATERAL to move the unnest from the select-list section to the FROM clause.

​David J.

pgsql-general by date:

Previous
From: Thiemo Kellner
Date:
Subject: array UNNESTed to rows stable with respect to order?
Next
From: Paul Jungwirth
Date:
Subject: Re: array UNNESTed to rows stable with respect to order?