mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
add clarification to docs
This commit is contained in:
parent
1b1a47e977
commit
55bc58006e
@ -71,8 +71,8 @@ Merges an [Array](../../sql-reference/data-types/array.md) of keys and an [Array
|
|||||||
|
|
||||||
|
|
||||||
The function is a more convenient alternative to `CAST((key_array, value_array_or_map), 'Map(key_type, value_type)')`. For example, instead of writing `CAST((['aa', 'bb'], [4, 5]), 'Map(String, UInt32)')`, you can write `mapFromArrays(['aa', 'bb'], [4, 5])`.
|
The function is a more convenient alternative to `CAST((key_array, value_array_or_map), 'Map(key_type, value_type)')`. For example, instead of writing `CAST((['aa', 'bb'], [4, 5]), 'Map(String, UInt32)')`, you can write `mapFromArrays(['aa', 'bb'], [4, 5])`.
|
||||||
|
|
||||||
|
|
||||||
**Syntax**
|
**Syntax**
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
@ -85,11 +85,11 @@ Alias: `MAP_FROM_ARRAYS(keys, values)`
|
|||||||
|
|
||||||
- `keys` — Given key array to create a map from. The nested type of array must be: [String](../../sql-reference/data-types/string.md), [Integer](../../sql-reference/data-types/int-uint.md), [LowCardinality](../../sql-reference/data-types/lowcardinality.md), [FixedString](../../sql-reference/data-types/fixedstring.md), [UUID](../../sql-reference/data-types/uuid.md), [Date](../../sql-reference/data-types/date.md), [DateTime](../../sql-reference/data-types/datetime.md), [Date32](../../sql-reference/data-types/date32.md), [Enum](../../sql-reference/data-types/enum.md)
|
- `keys` — Given key array to create a map from. The nested type of array must be: [String](../../sql-reference/data-types/string.md), [Integer](../../sql-reference/data-types/int-uint.md), [LowCardinality](../../sql-reference/data-types/lowcardinality.md), [FixedString](../../sql-reference/data-types/fixedstring.md), [UUID](../../sql-reference/data-types/uuid.md), [Date](../../sql-reference/data-types/date.md), [DateTime](../../sql-reference/data-types/datetime.md), [Date32](../../sql-reference/data-types/date32.md), [Enum](../../sql-reference/data-types/enum.md)
|
||||||
- `values` - Given value array or map to create a map from.
|
- `values` - Given value array or map to create a map from.
|
||||||
|
|
||||||
**Returned value**
|
**Returned value**
|
||||||
|
|
||||||
- A map whose keys and values are constructed from the key array and value array/map.
|
- A map whose keys and values are constructed from the key array and value array/map.
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
Query:
|
Query:
|
||||||
@ -406,13 +406,13 @@ mapContainsKeyLike(map, pattern)
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Arguments**
|
**Arguments**
|
||||||
- `map` — Map. [Map](../../sql-reference/data-types/map.md).
|
- `map` — Map. [Map](../../sql-reference/data-types/map.md).
|
||||||
- `pattern` - String pattern to match.
|
- `pattern` - String pattern to match.
|
||||||
|
|
||||||
**Returned value**
|
**Returned value**
|
||||||
|
|
||||||
- `1` if `map` contains `key` like specified pattern, `0` if not.
|
- `1` if `map` contains `key` like specified pattern, `0` if not.
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
Query:
|
Query:
|
||||||
@ -443,10 +443,10 @@ mapExtractKeyLike(map, pattern)
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Arguments**
|
**Arguments**
|
||||||
|
|
||||||
- `map` — Map. [Map](../../sql-reference/data-types/map.md).
|
- `map` — Map. [Map](../../sql-reference/data-types/map.md).
|
||||||
- `pattern` - String pattern to match.
|
- `pattern` - String pattern to match.
|
||||||
|
|
||||||
**Returned value**
|
**Returned value**
|
||||||
|
|
||||||
- A map contained elements the key of which matchs the specified pattern. If there are no elements matched the pattern, it will return an empty map.
|
- A map contained elements the key of which matchs the specified pattern. If there are no elements matched the pattern, it will return an empty map.
|
||||||
@ -481,7 +481,7 @@ mapApply(func, map)
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Arguments**
|
**Arguments**
|
||||||
|
|
||||||
- `func` - [Lambda function](../../sql-reference/functions/index.md#higher-order-functions---operator-and-lambdaparams-expr-function).
|
- `func` - [Lambda function](../../sql-reference/functions/index.md#higher-order-functions---operator-and-lambdaparams-expr-function).
|
||||||
- `map` — [Map](../../sql-reference/data-types/map.md).
|
- `map` — [Map](../../sql-reference/data-types/map.md).
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ mapFilter(func, map)
|
|||||||
**Arguments**
|
**Arguments**
|
||||||
|
|
||||||
- `func` - [Lambda function](../../sql-reference/functions/index.md#higher-order-functions---operator-and-lambdaparams-expr-function).
|
- `func` - [Lambda function](../../sql-reference/functions/index.md#higher-order-functions---operator-and-lambdaparams-expr-function).
|
||||||
- `map` — [Map](../../sql-reference/data-types/map.md).
|
- `map` — [Map](../../sql-reference/data-types/map.md).
|
||||||
|
|
||||||
**Returned value**
|
**Returned value**
|
||||||
|
|
||||||
@ -601,9 +601,9 @@ mapConcat(maps)
|
|||||||
|
|
||||||
**Returned value**
|
**Returned value**
|
||||||
|
|
||||||
- Returns a map with concatenated maps passed as arguments.
|
- Returns a map with concatenated maps passed as arguments. If there are same keys in two or more maps, all of them are added to the result map, but only the first one is accessible via operator `[]`
|
||||||
|
|
||||||
**Example**
|
**Examples**
|
||||||
|
|
||||||
Query:
|
Query:
|
||||||
|
|
||||||
@ -619,6 +619,20 @@ Result:
|
|||||||
└──────────────────────────────┘
|
└──────────────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Query:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT mapConcat(map('key1', 1, 'key2', 2), map('key1', 3)) AS map, map['key1'];
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
```text
|
||||||
|
┌─map──────────────────────────┬─elem─┐
|
||||||
|
│ {'key1':1,'key2':2,'key1':3} │ 1 │
|
||||||
|
└──────────────────────────────┴──────┘
|
||||||
|
```
|
||||||
|
|
||||||
## mapExists(\[func,\], map)
|
## mapExists(\[func,\], map)
|
||||||
|
|
||||||
Returns 1 if there is at least one key-value pair in `map` for which `func(key, value)` returns something other than 0. Otherwise, it returns 0.
|
Returns 1 if there is at least one key-value pair in `map` for which `func(key, value)` returns something other than 0. Otherwise, it returns 0.
|
||||||
|
Loading…
Reference in New Issue
Block a user