Created
January 23, 2013 05:19
-
-
Save ryandotsmith/4602274 to your computer and use it in GitHub Desktop.
Postgres array concatenation aggregate function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE AGGREGATE array_accum (anyarray) | |
( | |
sfunc = array_cat, | |
stype = anyarray, | |
initcond = '{}' | |
); |
This is pretty sweet 👍
Great!
Great Job. Thanks.
Simple and useful ! Thanks !
had to change it for pg 14:
CREATE AGGREGATE array_accum (anycompatiblearray)
(
sfunc = array_cat,
stype = anycompatiblearray,
initcond = '{}'
);
This is great! Is it possible to adapt this so that you can make the array items distinct?
Example of what I'm thinking:
array_accum(distinct "duplicateList")
had to change it for pg 14:
CREATE AGGREGATE array_accum (anycompatiblearray) ( sfunc = array_cat, stype = anycompatiblearray, initcond = '{}' );
Thanks, this version worked for me!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Useful and works like a charm. Perhaps consider proposing on the pg-dev list to include it in future version.