Re: [patch] Proposal for \crosstabview in psql

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: [patch] Proposal for \crosstabview in psql
Дата
Msg-id CAEZATCXCRL-Y1t4uihvWNX6r_D4OTRwNqfiZ-cajxUH_N60sqg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [patch] Proposal for \crosstabview in psql  (Andres Freund <andres@anarazel.de>)
Ответы Re: [patch] Proposal for \crosstabview in psql  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: [patch] Proposal for \crosstabview in psql  ("Daniel Verite" <daniel@manitou-mail.org>)
Re: [patch] Proposal for \crosstabview in psql  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Список pgsql-hackers
On 11 February 2016 at 08:43, Andres Freund <andres@anarazel.de> wrote:
> On 2016-02-09 09:27:04 +0000, Dean Rasheed wrote:
>> Looking at this patch, I have mixed feelings about it. On the one hand
>> I really like the look of the output, and I can see that the non-fixed
>> nature of the output columns makes this hard to achieve server-side.
>
>> But on the other hand, this seems to be going way beyond the normal
>> level of result formatting that something like \x does, and I find the
>> syntax for sorting particularly ugly.
>
> I've pretty similar doubts. Addinging features to psql which are complex
> enough that it's likely that people will be forced to parse psql
> output...  On the other hand, a proper server side solution won't be
> easy; so maybe this is a okay enough stopgap.
>

Well to be clear, I like the idea of this feature, and I'm not trying
to stand in the way of progressing it. However, I can't see myself
committing it in its current form.

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. Sorting columns is a little more understandable, since
there is no way for the original query to control the order in which
the colV values come out, but Tom raises a good point -- there are far
too many bells and whistles when it comes to sorting, and we don't
want to be adding all of them to the psql syntax.

Thinking about this some more though, perhaps *sorting* the columns is
the wrong way to be thinking about it. Perhaps a better approach would
be to allow the columns to be *listed* (optionally, using a separate
query). Something like the following (don't get too hung up on the
syntax):

SELECT name,      to_char(date, 'Mon') AS month,      sum(amount) AS amountFROM invoicesGROUP BY 1,2ORDER BY name
\crosstabview cols = (select to_char(d, 'Mon') from
generate_series('2000-01-01'::date, '2000-12-01', '1 month') d)

Regards,
Dean



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

Предыдущее
От: Artur Zakirov
Дата:
Сообщение: Re: [PROPOSAL] Improvements of Hunspell dictionaries support
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: [patch] Proposal for \crosstabview in psql