Re: [GENERAL] Are multiple array_aggs going to be in the same order?

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: [GENERAL] Are multiple array_aggs going to be in the same order?
Дата
Msg-id CAHyXU0xgtJW-MGrLhzGJw78LcHybbc=b4gd9CPn76vfOjaJKTg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [GENERAL] Are multiple array_aggs going to be in the same order?  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
On Mon, Apr 10, 2017 at 1:43 PM, Merlin Moncure <mmoncure@gmail.com> wrote:
> On Mon, Apr 10, 2017 at 1:35 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>
>> Yes, and in fact we documented the ORDER-BY-in-subselect solution back
>> before we had the ORDER-BY-in-aggregate feature.  I don't remember exactly
>> where, but I'm sure it's still described somewhere.  So it is documented
>> behavior that an aggregate without its own ORDER BY will see the rows in
>> whatever order the FROM clause supplies them.
>
> The documentation is a bit ambiguous on the topic TBH.    Via
> https://www.postgresql.org/docs/9.6/static/functions-aggregate.html:
>
> "The aggregate functions array_agg, json_agg, jsonb_agg,
> json_object_agg, jsonb_object_agg, string_agg, and xmlagg, as well as
> similar user-defined aggregate functions, produce meaningfully
> different result values depending on the order of the input values.
> This ordering is unspecified by default, but can be controlled by
> writing an ORDER BY clause within the aggregate call, as shown in
> Section 4.2.7. Alternatively, supplying the input values from a sorted
> subquery will usually work.
<snip>

What do you think about injecting the following lingo?

... depending on the order of the input values. This ordering is
unspecified by default, but can be controlled by ...

would be changed to

... depending on the order of the input values. Input value ordering
will be consistent across multiple order dependent aggregate functions
across the same grouping but is otherwise unspecified by default as
long as all there is no explicit ordering for any aggregate function
in the grouping.  Furthermore, input value ordering can be controlled
by ...

merlin


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

Предыдущее
От: Paul Jungwirth
Дата:
Сообщение: Re: [GENERAL] Are multiple array_aggs going to be in the same order?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [GENERAL] Are multiple array_aggs going to be in the same order?