Re: [SQL] UNNEST result order vs Array data

2013-06-20 Thread David Johnston
gmb wrote >>> The best, which you won't >>> like, is to wait for 9.4 where unnest() will most likely have a WITH >>> ORDINALITY option and you can sort on that. > > The fact that this type of thing is on the 9.4 roadmap indicates (to me, > in any case) that there are problems with the UNNEST f

Re: [SQL] UNNEST result order vs Array data

2013-06-20 Thread gmb
>> The best, which you won't >> like, is to wait for 9.4 where unnest() will most likely have a WITH >> ORDINALITY option and you can sort on that. The fact that this type of thing is on the 9.4 roadmap indicates (to me, in any case) that there are problems with the UNNEST functionality in the

Re: [SQL] UNNEST result order vs Array data

2013-06-20 Thread gmb
>> An array is ordered. If you turn it into a relation then it isn't >> ordered any more until you apply ORDER BY. >> >> An unnest() will almost certainly scan the array in-order, but once you >> embed that in a large query the ordering is no longer guaranteed. Thanks, I assumed as much. Apprec

Re: [SQL] UNNEST result order vs Array data

2013-06-20 Thread Vik Fearing
On 06/20/2013 01:00 PM, gmb wrote: > Can you please give me an example of how the order is specified? > I want the result of the UNNEST to be in the order of the array field > E.g. > SELECT UNNEST ( ARRAY[ 'abc' , 'ggh' , '12aa' , '444f' ] ); > Should always return: > > unnest > > abc >

Re: [SQL] UNNEST result order vs Array data

2013-06-20 Thread Richard Huxton
On 20/06/13 12:15, Achilleas Mantzios wrote: On 20/06/2013 13:45, Vik Fearing wrote: On 06/20/2013 12:40 PM, gmb wrote: Hi all I just want to confirm something regarding UNNEST function used with arrays. I cannot see that it is specifically mentioned in the documentation , but maybe because it

Re: [SQL] UNNEST result order vs Array data

2013-06-20 Thread Achilleas Mantzios
On 20/06/2013 13:45, Vik Fearing wrote: On 06/20/2013 12:40 PM, gmb wrote: Hi all I just want to confirm something regarding UNNEST function used with arrays. I cannot see that it is specifically mentioned in the documentation , but maybe because it is obvious. Is the order of the result guaran

Re: [SQL] UNNEST result order vs Array data

2013-06-20 Thread gmb
Hi Vik Thanks for the reply. Can you please give me an example of how the order is specified? I want the result of the UNNEST to be in the order of the array field E.g. SELECT UNNEST ( ARRAY[ 'abc' , 'ggh' , '12aa' , '444f' ] ); Should always return: unnest abc ggh 12aa 444f How sh

Re: [SQL] UNNEST result order vs Array data

2013-06-20 Thread Vik Fearing
On 06/20/2013 12:40 PM, gmb wrote: > Hi all > I just want to confirm something regarding UNNEST function used with arrays. > I cannot see that it is specifically mentioned in the documentation , but > maybe because it is obvious. > > Is the order of the result guaranteed to be the order of the arra

[SQL] UNNEST result order vs Array data

2013-06-20 Thread gmb
Hi all I just want to confirm something regarding UNNEST function used with arrays. I cannot see that it is specifically mentioned in the documentation , but maybe because it is obvious. Is the order of the result guaranteed to be the order of the array I.e. is it possible that: SELECT UNNEST( AR