Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: added arrayCompact function #7930

Merged
merged 3 commits into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 29 additions & 11 deletions docs/en/query_language/functions/array_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ SELECT arrayDifference([0, 10000000000000000000])

## arrayDistinct(arr) {#array_functions-arraydistinct}

Takes an array, returns an array containing the distinct elements.
Takes an array, returns an array containing the distinct elements.

Example:

Expand All @@ -698,7 +698,7 @@ SELECT arrayDistinct([1, 2, 2, 3, 1])

## arrayEnumerateDense(arr) {#array_functions-arrayenumeratedense}

Returns an array of the same size as the source array, indicating where each element first appears in the source array.
Returns an array of the same size as the source array, indicating where each element first appears in the source array.

Example:

Expand Down Expand Up @@ -808,22 +808,40 @@ SELECT arrayReverse([1, 2, 3])

Synonym for ["arrayReverse"](#array_functions-arrayreverse)

[Original article](https://clickhouse.yandex/docs/en/query_language/functions/array_functions/) <!--hide-->
## arrayCompact {#arraycompact}

## arrayCompact(arr) {#array_functions-arraycompact}
Removes consecutive duplicate elements from an array. The order of result values is determined by the order in the source array.

Takes an array, returns an array with consecutive duplicate elements removed.
**Syntax**

Example:
```sql
arrayCompact(arr)
```

**Parameters**

`arr` — The [array](../../data_types/array.md) to inspect.

**Returned value**

The array without duplicate.

Type: `Array`.

**Example**

Query:

```sql
SELECT arrayCompact([1, 2, 2, 3, 2, 3, 3])
SELECT arrayCompact([1, 1, nan, nan, 2, 3, 3, 3])
```

Result:

```text
┌─arrayCompact([1, 2, 2, 3, 2, 3, 3])──┐
│ [1,2,3,2,3] │
└──────────────────────────────────────┘
┌─arrayCompact([1, 1, nan, nan, 2, 3, 3, 3])─┐
│ [1,nan,nan,2,3]
└────────────────────────────────────────────
```

##
[Original article](https://clickhouse.yandex/docs/en/query_language/functions/array_functions/) <!--hide-->
36 changes: 36 additions & 0 deletions docs/ru/query_language/functions/array_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -814,4 +814,40 @@ SELECT arrayReverse([1, 2, 3])
Синоним для ["arrayReverse"](#array_functions-arrayreverse)


## arrayCompact {#arraycompact}

Удаляет дубликаты из массива. Порядок результирующих значений определяется порядком в исходном массиве.

**Синтаксис**

```sql
arrayCompact(arr)
```

**Параметры**

`arr` — [Массив](../../data_types/array.md) для обхода.

**Возвращаемое значение**

Массив без дубликатов.

Тип: `Array`.

**Пример**

Запрос:

```sql
SELECT arrayCompact([1, 1, nan, nan, 2, 3, 3, 3])
```

Ответ:

```text
┌─arrayCompact([1, 1, nan, nan, 2, 3, 3, 3])─┐
│ [1,nan,nan,2,3] │
└────────────────────────────────────────────┘
```

[Оригинальная статья](https://clickhouse.yandex/docs/ru/query_language/functions/array_functions/) <!--hide-->