Re: [patch] A \pivot command for psql

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: [patch] A \pivot command for psql
Дата
Msg-id cd521513-1349-4698-b93c-693199962e23@mm
обсуждение исходный текст
Ответ на Re: [patch] A \pivot command for psql  (David Fetter <david@fetter.org>)
Список pgsql-hackers
David Fetter wrote:

> That said, a thing in psql that could slice serialized output into
> columns would be handy as a broad, general part of reporting in
> psql

To avoid any confusion with server-side PIVOT, I suggest that the
currently proposed command in psql should have a different name
than \pivot.

The general idea is indeed pivoting, but what it precisely does
is project a resultset from a 3-column query onto cells in a
2D grid-like arrangement.

It differs significantly from what existing PIVOT SQL commands
do, looking closely at them it appears in particular that:

- they don't care about a leftmost column to hold "row titles", whereas it's essential to the psql feature.

- as mentioned upthread, the need to enumerate in advance the output columns is a crucial point with the SQL pivot,
whereaspsql doesn't care, as it just displays a resultset that is already obtained. 

- they operate with an aggregate function at their heart, whereas it's also irrelevant to the psql display feature
whetherthere's an aggregate  in the query. 

For a different name, I've thought of these alternatives that belong
to client-side vocabulary:

\rotate
\sheetview
\gridview
\grid3view (to insist that it works on 3 columns).
\matrix
\matview
\matrixview
\crosstab (at the risk of confusion with the contrib feature)

Opinions? I'd go for \rotate personally.

Also I'll try to demonstrate use case with concrete examples.

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite



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

Предыдущее
От: David Steele
Дата:
Сообщение: Re: Test code is worth the space
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Test code is worth the space