Re: Review: UNNEST (and other functions) WITH ORDINALITY

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Review: UNNEST (and other functions) WITH ORDINALITY
Дата
Msg-id 51CA343A.6050808@agliodbs.com
обсуждение исходный текст
Ответ на Review: UNNEST (and other functions) WITH ORDINALITY  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Ответы Re: Review: UNNEST (and other functions) WITH ORDINALITY  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Review: UNNEST (and other functions) WITH ORDINALITY  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Список pgsql-hackers
Folks,

(the below was already discussed on IRC)

Leaving names aside on this patch, I'm wondering about a piece of
functionality I have with the current unnest() and with the
unnest_ordinality()[1] extension: namely, the ability to unnest several
arrays "in parallel" by using unnest() in the target list.

For example, given the table:

lotsarrays (id serial PK,arr1 int[],arr2 numeric[],arr3 boolean[]
)

I can currently do:

SELECT id,unnest(arr1) as arr1,unnest(arr2) as arr2,unnest(arr3) as arr3
FROM lotsarrays;

... and if arr1, 2 and 3 are exactly the same length, this creates a
coordinated dataset.   I can even use the unnest_ordinality() extension
function to get the ordinality of this combined dataset:

SELECT id,(unnest_ordinality(arr1)).element_number as array_index,unnest(arr1) as arr1,unnest(arr2) as
arr2,unnest(arr3)as arr3
 
FROM lotsarrays;

There are reasons why this will be complicated to implement WITH
ORDINALITY; DF, Andrew and I discussed them on IRC.  So allowing WITH
ORDINALITY in the target list is a TODO, either for later in 9.4
development, or for 9.5.

So, this isn't stopping the patch; I just want a TODO for "implement
WITH ORDINALITY in the target list for SRFs".

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: FILTER for aggregates [was Re: Department of Redundancy Department: makeNode(FuncCall) division]
Следующее
От: Brendan Jurd
Дата:
Сообщение: Re: Kudos for Reviewers -- straw poll