| Query | Return Data-Type | Result |
SELECT anyarray_concat(
ARRAY[1, 2],
ARRAY[2, 3]
) | integer[] | {1,2,2,3} |
SELECT anyarray_concat(
ARRAY['one', 'two'],
ARRAY['two', 'three']
) | text[] | {one,two,two,three} |
SELECT anyarray_concat(
ARRAY[1, 2],
2
) | integer[] | {1,2,2} |
SELECT anyarray_concat(
ARRAY['one', 'two'],
'two'::text
) | text[] | {one,two,two} |
SELECT anyarray_concat_uniq(
ARRAY[1, 2],
ARRAY[2, 3]
) | integer[] | {1,2,3} |
SELECT anyarray_concat_uniq(
ARRAY['one', 'two'],
ARRAY['two', 'three']
) | text[] | {one,two,three} |
SELECT anyarray_concat_uniq(
ARRAY[1, 2],
2
) | integer[] | {1,2} |
SELECT anyarray_concat_uniq(
ARRAY[1, 2],
3
) | integer[] | {1,2,3} |
SELECT anyarray_concat_uniq(
ARRAY['one', 'two'],
'two'::text
) | text[] | {one,two} |
SELECT anyarray_concat_uniq(
ARRAY['one', 'two'],
'three'::text
) | text[] | {one,two,three} |
SELECT anyarray_diff(
ARRAY[1, 1, 2],
ARRAY[2, 3, 4, 4]
) | integer[] | {1,1,3,4,4} |
SELECT anyarray_diff(
ARRAY['one', 'one', 'two'],
ARRAY['two', 'three', 'four', 'four']
) | text[] | {one,one,three,four,four} |
SELECT anyarray_diff_uniq(
ARRAY[1, 1, 2],
ARRAY[2, 3, 4, 4]
) | integer[] | {1,3,4} |
SELECT anyarray_diff_uniq(
ARRAY['one', 'one', 'two'],
ARRAY['two', 'three', 'four', 'four']
) | text[] | {one,three,four} |
SELECT *
FROM anyarray_enumerate(
ARRAY[
'foo', 'bar', 'spam', 'eggs'
]::TEXT[]
); |
TABLE (index bigint, value text) |
{1,'foo'}
{2,'bar'}
{3,'spam'}
{4,'eggs'} |
SELECT *
FROM anyarray_enumerate(
ARRAY[
ARRAY['foo', 'bar'],
ARRAY['spam', 'eggs']
]::TEXT[]
); |
TABLE (index bigint, value text) |
{1,'foo'}
{2,'bar'}
{3,'spam'}
{4,'eggs'} |
SELECT anyarray_numeric_only(
ARRAY['1', '1.1', '1.1a', '1.a', 'a']::text[]
) | text[] | {1,1.1} |
SELECT anyarray_numeric_only(
ARRAY[1, 1.1, 1.1234567890]::numeric[]
) | numeric[] | {1,1.1,1.1234567890} |
SELECT anyarray_is_array(ARRAY[1, 2]) | boolean[] | TRUE |
SELECT anyarray_is_array(ARRAY['one', 'two']) | boolean[] | TRUE |
SELECT anyarray_is_array(1) | boolean[] | FALSE |
SELECT anyarray_is_array('one'::text) | boolean[] | FALSE |
SELECT anyarray_ranges(ARRAY[1, 2, 4, 5, 6, 9]) | text[] | {1-2,4-6,9} |
SELECT anyarray_ranges(ARRAY[1.1, 1.2, 2, 3, 5]) | text[] | {1.1,1.2,2-3,5} |
SELECT anyarray_remove(
ARRAY[1, 2],
ARRAY[2, 3]
) | integer[] | {1} |
SELECT anyarray_remove(
ARRAY['one', 'two'],
ARRAY['two', 'three']
) | text[] | {one} |
SELECT anyarray_remove(
ARRAY[1, 2],
2
) | integer[] | {1} |
SELECT anyarray_remove(
ARRAY['one', 'two'],
'two'::text
) | text[] | {one} |
SELECT anyarray_remove_null(ARRAY[1, 2, NULL, 4]) | integer[] | {1,2,4} |
SELECT anyarray_remove_null(ARRAY['one', 'two', NULL, 'four']) | text[] | {one,two,four} |
SELECT anyarray_sort(ARRAY[1, 46, 15, 3]) | integer[] | {1,3,15,46} |
SELECT anyarray_sort(ARRAY['1', '46', '15', '3']) | integer[] | {1,15,3,46} |
SELECT anyarray_sort(ARRAY['one', 'forty-six', 'fifteen', 'three']) | text[] | {fifteen,forty-six,one,three} |
SELECT anyarray_uniq(ARRAY[1, 2, 3, 2, 1]) | integer[] | {1,2,3} |
SELECT anyarray_uniq(ARRAY['one', 'two', 'three', 'two', 'one']) | text[] | {one,two,three} |
SELECT id, anyarray_agg(list)
FROM (VALUES
('a', ARRAY[1,2]),
('a', ARRAY[3,4]),
('b', ARRAY[5,6]),
('b', ARRAY[7,8])
) AS data (id, list)
GROUP BY id | text, integer[] | 'a', {1,2,3,4}
'b', {5,6,7,8} |
SELECT id, anyarray_agg(ARRAY[list])
FROM (VALUES
('a', ARRAY[1,2]),
('a', ARRAY[3,4]),
('b', ARRAY[5,6]),
('b', ARRAY[7,8])
) AS data (id, list)
GROUP BY id | text, integer[] | 'a', {{1,2},{3,4}} 'b', {{5,6},{7,8}} |