Re: [patch] Proposal for \crosstabview in psql

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: [patch] Proposal for \crosstabview in psql
Дата
Msg-id 68c79d96-4640-4884-b3c1-099f7fa9fb7d@mm
обсуждение исходный текст
Ответ на Re: [patch] Proposal for \crosstabview in psql  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Ответы Re: [patch] Proposal for \crosstabview in psql  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Список pgsql-hackers
Dean Rasheed wrote:

> My biggest problem is with the sorting, for all the reasons discussed
> above. There is absolutely no reason for \crosstabview to be
> re-sorting rows -- they should just be left in the original query
> result order

We want the option to sort the vertical the header in a late additional
step when the ORDER BY of the query is already assigned to another
purpose.

I've submitted this example on the wiki:
https://wiki.postgresql.org/wiki/Crosstabview

create view v_data as
select * from ( values  ('v1','h2','foo', '2015-04-01'::date),  ('v2','h1','bar', '2015-01-02'),  ('v1','h0','baz',
'2015-07-12'), ('v0','h4','qux', '2015-07-15')) as l(v,h,c,d); 


Normal top-down display:

select v,to_char(d,'Mon') as m, c  from v_data order by d;
v  |  m  |  c
----+-----+-----v2 | Jan | barv1 | Apr | foov1 | Jul | bazv0 | Jul | qux

Crosstabview display without any additional sort:
\crosstabview v m c
v  | Jan | Apr | Jul
----+-----+-----+-----v2 | bar |    | v1 |      | foo | bazv0 |      |    | qux

"d" is not present the resultset but it drives the sort
so that month names come out in the natural order.

\crosstabview does not discard the order of colH nor the order of colV,
it follows both, so that we get v2,v1,v0 in this order in the leftmost
column (vertical header) just like in the resultset.

At this point, it seems to me that it's perfectly reasonable for our user
to expect the possibility of sorting additionally by "v" , without
changing the query and without changing the order of the horizontal
header:
\crosstabview +v m c
v  | Jan | Apr | Jul
----+-----+-----+-----v0 |      |    | quxv1 |      | foo | bazv2 | bar |    |



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



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

Предыдущее
От: Teodor Sigaev
Дата:
Сообщение: Re: Small PATCH: check of 2 Perl modules
Следующее
От: Alexander Korotkov
Дата:
Сообщение: Re: WIP: Access method extendability