Re: [BUGS] BUG #14626: array_agg( anyarray ) unexpected error withmulti-valued single-dimension array

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [BUGS] BUG #14626: array_agg( anyarray ) unexpected error withmulti-valued single-dimension array
Дата
Msg-id CAKFQuwbRLF0dcqBs6BGU_D4EfuVqOqZX3xoxJdkmiGz3-AxE2A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [BUGS] BUG #14626: array_agg( anyarray ) unexpected error with multi-valued single-dimension array  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [BUGS] BUG #14626: array_agg( anyarray ) unexpected error withmulti-valued single-dimension array  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-bugs
On Wed, Apr 19, 2017 at 1:03 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
david.g.johnston@gmail.com writes:
> This doesn't, and should since the number of elements in the non-empty array
> shouldn't change the dimensionality logic.

> SELECT array_agg(CASE WHEN a = ARRAY[]::text[] THEN ARRAY['N/A']::text[]
> ELSE a END)
> FROM ( VALUES (1, ARRAY[]::text[]), (1, ARRAY['1','2']::text[]) ) vals (v,
> a)

Why do you think that should work?  You're asking array_agg to accumulate
a 1-D length-1 array and then a 1-D length-2 array.  There's no way to
make a rectangular 2-D array out of that, except perhaps by inventing
entries which isn't in array_agg's charter.

I was being too narrow-minded in interpreting the word dimension.​

​SELECT array_ndims(ARRAY['1','2']::text[]); => 1; therefore it is a one dimensional array - having a length of 2.  One can, and we do in other places, define that array as having a dimension of 1x2.

SELECT '{{N/A},{1,2}}'::text[] --> fails with "sub-arrays with matching dimensions"...

Apparently the annoyance I posted on the other thread isn't so simple to resolve - just having an empty "1-dimensional" array is not particularly useful given the length dimension must also match.

This helps explain why my first attempt:

SELECT array_dims('{1,2}'::text[]); --> yields [1:2] which is what is being keyed off here.

All this and all I really want is a friggin' "array_append / array_concat" aggregate function that accepts either scalars or matching "primary dimension" arrays - and treats empty arrays as no-ops.

David J.

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

Предыдущее
От: Nico Williams
Дата:
Сообщение: Re: [BUGS] pg_dump(1) failures when concurrently refreshing mat views
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [BUGS] pg_dump(1) failures when concurrently refreshing mat views