相关函数 适用于: Databricks SQL Databricks Runtime 从array中删除重复值。 语法 复制 array_distinct(array) 参数 array:一个数组表达式。 返回 函数返回与输入参数类型相同的数组,其中已删除所有重复值。 示例 SQL >SELECTarray_distinct(array(1,2,3,NULL,3)); [1,2,3,NULL] ...
CREATE OR REPLACE FUNCTION array_append_distinct(anyarray, anyelement) RETURNS anyarray AS $$ SELECT ARRAY(SELECT unnest($1) union SELECT $2) $$ LANGUAGE sql; postgres=# select array_append_distinct(array[1,2,3,4],1); array_append_distinct --- {1,2,3,4} (1 row) postgres=# selec...
*@paramarray $array1 Array which will be overwritten. *@paramarray $array2 Array who will overwrite. *@returnarray */functionarray_merge_recursive_distinct($array1, $array2){ $merged = $array1;foreach($array2as$key => &$value) { $merged[$key] = is_array($value) &&isset($merged[$...
CREATE OR REPLACE FUNCTION array_append_distinct(anyarray, anyelement) RETURNS anyarray AS $$ SELECT ARRAY(SELECT unnest($1) union SELECT $2) $$ LANGUAGE sql; postgres=# select array_append_distinct(array[1,2,3,4],1); array_append_distinct --- {1,2,3,4} (1 row) postgres=# selec...
CREATE OR REPLACE FUNCTION array_append_distinct(anyarray, anyelement) RETURNS anyarray AS $$ SELECT ARRAY(SELECT unnest($1) union SELECT $2) $$ LANGUAGE sql; postgres=# select array_append_distinct(array[1,2,3,4],1); array_append_distinct --- {1,2,3,4} (1 row) postgres=# selec...