DOCS-6182: The flatten function docs (#7661)

* Array flatten function description (#67)

* docs(flatten): add flatten description

* docs(flatten): flatten description

* docs(flatten): flatten description (minor changes)

* docs(flatten): add flatten description

* docs(flatten): flatten description

* docs(flatten): flatten description (minor changes)

* docs(flatten): changing description

* DOCAPI-6182: The flatten function docs

* Update docs/en/query_language/functions/array_functions.md

Co-Authored-By: Ivan Blinkov <github@blinkov.ru>

* DOCAPI-6182: Switched names.
This commit is contained in:
BayoNet 2019-12-03 13:11:13 +03:00 committed by GitHub
parent 0c904f1484
commit e86a1cd68e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -772,22 +772,6 @@ SELECT arrayReduce('uniqUpTo(3)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
└─────────────────────────────────────────────────────────────┘
```
## arrayFlatten(arr) {#array_functions-arrayflatten}
The `arrayFlatten` (or `flatten` alias) method will collapse the elements of an array to create a single array.
Example:
```sql
SELECT arrayFlatten([[1, 2, 3], [4, 5]])
```
```text
┌─arrayFlatten([[1, 2, 3], [4, 5]])─┐
│ [1,2,3,4,5] │
└───────────────────────────────────┘
```
## arrayReverse(arr) {#array_functions-arrayreverse}
Returns an array of the same size as the original array containing the elements in reverse order.
@ -808,6 +792,44 @@ SELECT arrayReverse([1, 2, 3])
Synonym for ["arrayReverse"](#array_functions-arrayreverse)
## arrayFlatten {#arrayflatten}
Converts array of arrays to a flat array.
Function:
- Applies for any depth of nested arrays, but all the elements should lay at the same level.
For example, the `[[[1]], [[2], [3]]]` array can be flattened, but the `[[1], [[2], [3]]]` array can't be flattened.
- Does not change arrays that are already flat.
The flattened array contains all the elements from all source arrays.
**Syntax**
```sql
flatten(array_of_arrays)
```
Alias: `flatten`.
**Parameters**
- `array_of_arrays` — [Array](../../data_types/array.md) of arrays. For example, `[[1,2,3], [4,5]]`.
**Examples**
```sql
SELECT flatten([[[1]], [[2], [3]]])
```
```text
┌─flatten(array(array([1]), array([2], [3])))─┐
│ [1,2,3] │
└─────────────────────────────────────────────┘
```
## arrayCompact {#arraycompact}
Removes consecutive duplicate elements from an array. The order of result values is determined by the order in the source array.