From e4ba3b47fc97c503ca3e5168f405ab8e34732baa Mon Sep 17 00:00:00 2001 From: Peter Nguyen Date: Wed, 28 Aug 2024 00:16:02 -0600 Subject: [PATCH] Document arrayUnion() in array-functions.md --- .../sql-reference/functions/array-functions.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/en/sql-reference/functions/array-functions.md b/docs/en/sql-reference/functions/array-functions.md index 1b52440903d..e1516ae19d9 100644 --- a/docs/en/sql-reference/functions/array-functions.md +++ b/docs/en/sql-reference/functions/array-functions.md @@ -1717,6 +1717,24 @@ Result: [[1,1,2,3],[1,2,3,4]] ``` +## arrayUnion(arr) + +Takes multiple arrays, returns an array that contains all elements that are present in any of the source arrays. + +Example: +```sql +SELECT + arrayUnion([-2, 1], [10, 1], [-2], []) as num_example, + arrayUnion(['hi'], [], ['hello', 'hi']) as str_example, + arrayUnion([1, 3, NULL], [2, 3, NULL]) as null_example +``` + +```text +┌─num_example─┬─str_example────┬─null_example─┐ +│ [10,-2,1] │ ['hello','hi'] │ [3,2,1,NULL] │ +└─────────────┴────────────────┴──────────────┘ +``` + ## arrayIntersect(arr) Takes multiple arrays, returns an array with elements that are present in all source arrays.