Last active
May 3, 2021 21:48
-
-
Save garethflowers/2e626d6e53b8f07c8bd9 to your computer and use it in GitHub Desktop.
Returns an array with no NULL or '' (emtpy string) values
This file contains hidden or 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 OR REPLACE FUNCTION array_filter_blanks( | |
| ANYARRAY | |
| ) | |
| RETURNS ANYARRAY | |
| LANGUAGE sql | |
| IMMUTABLE | |
| STRICT | |
| AS $$ | |
| SELECT ARRAY( | |
| SELECT x | |
| FROM UNNEST( $1 ) AS x | |
| WHERE x IS NOT NULL | |
| AND x <> '' | |
| ); | |
| $$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment