This is an automated email from the ASF dual-hosted git repository. kassiez pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push: new b9aa25e302c [opt](function) optimize some map function docs (#1872) b9aa25e302c is described below commit b9aa25e302ce44ba8d1161cd546c00ac49846d9a Author: chaoyangqi <87635040+chaoyan...@users.noreply.github.com> AuthorDate: Mon Jan 20 15:56:15 2025 +0800 [opt](function) optimize some map function docs (#1872) ## Versions - [x] dev - [x] 3.0 - [x] 2.1 - [ ] 2.0 ## Languages - [x] Chinese - [x] English ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built --- .../map-functions/map-contains-key.md | 61 +++++++----------- .../map-functions/map-contains-value.md | 75 +++++++--------------- .../scalar-functions/map-functions/map-keys.md | 47 +++++++------- .../scalar-functions/map-functions/map-size.md | 37 ++++++++++- .../scalar-functions/map-functions/map-values.md | 48 +++++++------- .../scalar-functions/map-functions/map.md | 49 +++++++------- .../map-functions/map-contains-key.md | 57 +++++++--------- .../map-functions/map-contains-value.md | 71 ++++++-------------- .../scalar-functions/map-functions/map-keys.md | 40 ++++++------ .../scalar-functions/map-functions/map-size.md | 37 ++++++++++- .../scalar-functions/map-functions/map-values.md | 40 ++++++------ .../scalar-functions/map-functions/map.md | 43 +++++++------ .../map-functions/map-contains-key.md | 57 +++++++--------- .../map-functions/map-contains-value.md | 71 ++++++-------------- .../scalar-functions/map-functions/map-keys.md | 40 ++++++------ .../scalar-functions/map-functions/map-size.md | 37 ++++++++++- .../scalar-functions/map-functions/map-values.md | 40 ++++++------ .../scalar-functions/map-functions/map.md | 43 +++++++------ .../map-functions/map-contains-key.md | 57 +++++++--------- .../map-functions/map-contains-value.md | 71 ++++++-------------- .../scalar-functions/map-functions/map-keys.md | 40 ++++++------ .../scalar-functions/map-functions/map-size.md | 37 ++++++++++- .../scalar-functions/map-functions/map-values.md | 40 ++++++------ .../scalar-functions/map-functions/map.md | 43 +++++++------ .../map-functions/map-contains-key.md | 61 +++++++----------- .../map-functions/map-contains-value.md | 75 +++++++--------------- .../scalar-functions/map-functions/map-keys.md | 47 +++++++------- .../scalar-functions/map-functions/map-size.md | 37 ++++++++++- .../scalar-functions/map-functions/map-values.md | 48 +++++++------- .../scalar-functions/map-functions/map.md | 49 +++++++------- .../map-functions/map-contains-key.md | 61 +++++++----------- .../map-functions/map-contains-value.md | 75 +++++++--------------- .../scalar-functions/map-functions/map-keys.md | 47 +++++++------- .../scalar-functions/map-functions/map-size.md | 37 ++++++++++- .../scalar-functions/map-functions/map-values.md | 48 +++++++------- .../scalar-functions/map-functions/map.md | 49 +++++++------- 36 files changed, 900 insertions(+), 915 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index e5957fdc9e4..70bba730c09 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -24,50 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific key `key` -`BOOLEAN map_contains_key(Map<K, V> map, K key)` +## Syntax -Determines whether the given `map` contains a particular key `key`. +```sql +MAP_CONTAINS_KEY(<map>, <key>) +``` -### Example +## Parameters -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | +| `<key>` | The key to be retrieved | -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +Determines whether the given `map` contains a specific key `key`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) -``` +## Example -### Keywords +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); +``` -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 68c280c05b0..1eea84a410c 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -24,66 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific value `value` -`BOOLEAN map_contains_value(Map<K, V> map, V value)` - -Determines whether the given `map` contains a particular value `value`. - -### Example +## Syntax ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(<map>, <value>) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Parameters -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | +| `<value>` | The value to be retrieved | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +Determines whether the given `map` contains a specific value `value`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## Example -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 04e20a1cfb2..5bde39f09b9 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -23,35 +23,36 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> +## Description -### Description +Extract the keys of the given `map` into an `ARRAY` of the corresponding type -#### Syntax +## Syntax -`ARRAY<K> map_keys(Map<K, V> map)` +```sql +MAP_KEYS(<map>) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | -Extracts the keys of a given `map` into an `ARRAY` of the corresponding type. +## Return Value -### Example +Extract the keys of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 79f097a3ff5..15c78086b80 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "en" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +Count the number of elements in a Map + +## Syntax + +```sql +MAP_SIZE(<map>) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | + +## Return Value + +Returns the number of elements in the Map + +## Example + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index 6fef8da25aa..160fcb91ee7 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -24,34 +24,36 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Extract the values of the given `map` into an `ARRAY` of the corresponding type -`ARRAY<K> map_values(Map<K, V> map)` +## Syntax -Extracts the value of a given `map` into an `ARRAY` of the corresponding type. +```sql +MAP_VALUES(<map>) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | -### Example +## Return Value + +Extract the values of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 8ffda7f1030..f19716c0dc1 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -24,34 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Constructs a `Map<K, V>` of a specific type using some set of key-value pairs -`MAP<K, V> map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +## Syntax -Construct a type-specific `Map<K, V>` using a set of key-value pairs. +```sql +MAP( <key1> , <value1> [, <key2>,<value2> ... ]) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<key>` | Constructing the key of the map | +| `<value>` | Constructing the value of the map | -### Example +## Return Value + +Returns a specific type `Map<K, V>` constructed from a number of key-value pairs + +## Example ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index f6b0cdb8322..e1ce4ac677f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -26,48 +26,35 @@ under the License. ## 描述 +判断给定 `map` 中是否包含特定的键 `key` + ## 语法 -`BOOLEAN map_contains_key(Map<K, V> map, K key)` +```sql +MAP_CONTAINS_KEY(<map>, <key>) +``` -判断给定 `map` 中是否包含特定的键 `key` +## 参数 -## 举例 +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | +| `<key>` | 需要检索的key | -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +## 返回值 -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +判断给定 `map` 中是否包含特定的键 `key`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +## 举例 -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); ``` -### Keywords - -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 8e2eb5b56a7..c255f874055 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -26,64 +26,35 @@ under the License. ## 描述 -## 语法 - -`BOOLEAN map_contains_value(Map<K, V> map, V value)` - 判断给定 `map` 中是否包含特定的值 `value` -## 举例 +## 语法 ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(<map>, <value>) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 参数 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | +| `<value>` | 需要检索的 value | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 返回值 -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +判断给定 `map` 中是否包含特定的值 `value`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## 举例 -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 852b288f244..5579de67ce6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的键提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY<K> map_keys(Map<K, V> map)` +```sql +MAP_KEYS(<map>) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的键提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 85424d7fecd..b3ca337613d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "zh-CN" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +计算 Map 中元素的个数 + +## 语法 + +```sql +MAP_SIZE(<map>) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | + +## 返回值 + +返回 Map 中元素的个数 + +## 举例 + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index b5a0b2e27d3..955db06ddda 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的值提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY<K> map_values(Map<K, V> map)` +```sql +MAP_VALUES(<map>) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的值提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 80124e9a5d8..95896922640 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -26,32 +26,35 @@ under the License. ## 描述 +使用若干组键值对构造一个特定类型的 `Map<K, V>` + ## 语法 -`MAP<K, V> map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +```sql +MAP( <key1> , <value1> [, <key2>,<value2> ... ]) +``` -使用若干组键值对构造一个特定类型的 `Map<K, V>` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<key>` | 构造 map 的 key | +| `<value>` | 构造 map 的 value | + +## 返回值 + +返回由若干组键值对构造的特定类型 `Map<K, V>` ## 举例 ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index f6b0cdb8322..e1ce4ac677f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -26,48 +26,35 @@ under the License. ## 描述 +判断给定 `map` 中是否包含特定的键 `key` + ## 语法 -`BOOLEAN map_contains_key(Map<K, V> map, K key)` +```sql +MAP_CONTAINS_KEY(<map>, <key>) +``` -判断给定 `map` 中是否包含特定的键 `key` +## 参数 -## 举例 +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | +| `<key>` | 需要检索的key | -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +## 返回值 -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +判断给定 `map` 中是否包含特定的键 `key`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +## 举例 -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); ``` -### Keywords - -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 8e2eb5b56a7..c255f874055 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -26,64 +26,35 @@ under the License. ## 描述 -## 语法 - -`BOOLEAN map_contains_value(Map<K, V> map, V value)` - 判断给定 `map` 中是否包含特定的值 `value` -## 举例 +## 语法 ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(<map>, <value>) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 参数 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | +| `<value>` | 需要检索的 value | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 返回值 -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +判断给定 `map` 中是否包含特定的值 `value`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## 举例 -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 852b288f244..5579de67ce6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的键提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY<K> map_keys(Map<K, V> map)` +```sql +MAP_KEYS(<map>) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的键提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 85424d7fecd..b3ca337613d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "zh-CN" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +计算 Map 中元素的个数 + +## 语法 + +```sql +MAP_SIZE(<map>) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | + +## 返回值 + +返回 Map 中元素的个数 + +## 举例 + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index b5a0b2e27d3..955db06ddda 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的值提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY<K> map_values(Map<K, V> map)` +```sql +MAP_VALUES(<map>) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的值提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 80124e9a5d8..95896922640 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -26,32 +26,35 @@ under the License. ## 描述 +使用若干组键值对构造一个特定类型的 `Map<K, V>` + ## 语法 -`MAP<K, V> map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +```sql +MAP( <key1> , <value1> [, <key2>,<value2> ... ]) +``` -使用若干组键值对构造一个特定类型的 `Map<K, V>` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<key>` | 构造 map 的 key | +| `<value>` | 构造 map 的 value | + +## 返回值 + +返回由若干组键值对构造的特定类型 `Map<K, V>` ## 举例 ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index f6b0cdb8322..e1ce4ac677f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -26,48 +26,35 @@ under the License. ## 描述 +判断给定 `map` 中是否包含特定的键 `key` + ## 语法 -`BOOLEAN map_contains_key(Map<K, V> map, K key)` +```sql +MAP_CONTAINS_KEY(<map>, <key>) +``` -判断给定 `map` 中是否包含特定的键 `key` +## 参数 -## 举例 +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | +| `<key>` | 需要检索的key | -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +## 返回值 -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +判断给定 `map` 中是否包含特定的键 `key`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +## 举例 -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); ``` -### Keywords - -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 8e2eb5b56a7..c255f874055 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -26,64 +26,35 @@ under the License. ## 描述 -## 语法 - -`BOOLEAN map_contains_value(Map<K, V> map, V value)` - 判断给定 `map` 中是否包含特定的值 `value` -## 举例 +## 语法 ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(<map>, <value>) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 参数 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | +| `<value>` | 需要检索的 value | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 返回值 -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +判断给定 `map` 中是否包含特定的值 `value`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## 举例 -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 852b288f244..5579de67ce6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的键提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY<K> map_keys(Map<K, V> map)` +```sql +MAP_KEYS(<map>) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的键提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 85424d7fecd..b3ca337613d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "zh-CN" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +计算 Map 中元素的个数 + +## 语法 + +```sql +MAP_SIZE(<map>) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | + +## 返回值 + +返回 Map 中元素的个数 + +## 举例 + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index b5a0b2e27d3..955db06ddda 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的值提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY<K> map_values(Map<K, V> map)` +```sql +MAP_VALUES(<map>) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<map>` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的值提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 80124e9a5d8..95896922640 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -26,32 +26,35 @@ under the License. ## 描述 +使用若干组键值对构造一个特定类型的 `Map<K, V>` + ## 语法 -`MAP<K, V> map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +```sql +MAP( <key1> , <value1> [, <key2>,<value2> ... ]) +``` -使用若干组键值对构造一个特定类型的 `Map<K, V>` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `<key>` | 构造 map 的 key | +| `<value>` | 构造 map 的 value | + +## 返回值 + +返回由若干组键值对构造的特定类型 `Map<K, V>` ## 举例 ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index e5957fdc9e4..70bba730c09 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -24,50 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific key `key` -`BOOLEAN map_contains_key(Map<K, V> map, K key)` +## Syntax -Determines whether the given `map` contains a particular key `key`. +```sql +MAP_CONTAINS_KEY(<map>, <key>) +``` -### Example +## Parameters -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | +| `<key>` | The key to be retrieved | -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +Determines whether the given `map` contains a specific key `key`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) -``` +## Example -### Keywords +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); +``` -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 68c280c05b0..1eea84a410c 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -24,66 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific value `value` -`BOOLEAN map_contains_value(Map<K, V> map, V value)` - -Determines whether the given `map` contains a particular value `value`. - -### Example +## Syntax ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(<map>, <value>) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Parameters -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | +| `<value>` | The value to be retrieved | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +Determines whether the given `map` contains a specific value `value`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## Example -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 04e20a1cfb2..5bde39f09b9 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -23,35 +23,36 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> +## Description -### Description +Extract the keys of the given `map` into an `ARRAY` of the corresponding type -#### Syntax +## Syntax -`ARRAY<K> map_keys(Map<K, V> map)` +```sql +MAP_KEYS(<map>) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | -Extracts the keys of a given `map` into an `ARRAY` of the corresponding type. +## Return Value -### Example +Extract the keys of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 79f097a3ff5..15c78086b80 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "en" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +Count the number of elements in a Map + +## Syntax + +```sql +MAP_SIZE(<map>) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | + +## Return Value + +Returns the number of elements in the Map + +## Example + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index 6fef8da25aa..160fcb91ee7 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -24,34 +24,36 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Extract the values of the given `map` into an `ARRAY` of the corresponding type -`ARRAY<K> map_values(Map<K, V> map)` +## Syntax -Extracts the value of a given `map` into an `ARRAY` of the corresponding type. +```sql +MAP_VALUES(<map>) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | -### Example +## Return Value + +Extract the values of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 8ffda7f1030..f19716c0dc1 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -24,34 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Constructs a `Map<K, V>` of a specific type using some set of key-value pairs -`MAP<K, V> map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +## Syntax -Construct a type-specific `Map<K, V>` using a set of key-value pairs. +```sql +MAP( <key1> , <value1> [, <key2>,<value2> ... ]) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<key>` | Constructing the key of the map | +| `<value>` | Constructing the value of the map | -### Example +## Return Value + +Returns a specific type `Map<K, V>` constructed from a number of key-value pairs + +## Example ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index e5957fdc9e4..70bba730c09 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -24,50 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific key `key` -`BOOLEAN map_contains_key(Map<K, V> map, K key)` +## Syntax -Determines whether the given `map` contains a particular key `key`. +```sql +MAP_CONTAINS_KEY(<map>, <key>) +``` -### Example +## Parameters -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | +| `<key>` | The key to be retrieved | -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +Determines whether the given `map` contains a specific key `key`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) -``` +## Example -### Keywords +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); +``` -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 68c280c05b0..1eea84a410c 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -24,66 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific value `value` -`BOOLEAN map_contains_value(Map<K, V> map, V value)` - -Determines whether the given `map` contains a particular value `value`. - -### Example +## Syntax ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(<map>, <value>) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(38, 9),VARCHAR(3)>), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Parameters -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP<DECIMALV3(3, 2),VARCHAR(3)>), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | +| `<value>` | The value to be retrieved | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +Determines whether the given `map` contains a specific value `value`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## Example -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 04e20a1cfb2..5bde39f09b9 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -23,35 +23,36 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> +## Description -### Description +Extract the keys of the given `map` into an `ARRAY` of the corresponding type -#### Syntax +## Syntax -`ARRAY<K> map_keys(Map<K, V> map)` +```sql +MAP_KEYS(<map>) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | -Extracts the keys of a given `map` into an `ARRAY` of the corresponding type. +## Return Value -### Example +Extract the keys of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 79f097a3ff5..15c78086b80 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "en" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +Count the number of elements in a Map + +## Syntax + +```sql +MAP_SIZE(<map>) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | + +## Return Value + +Returns the number of elements in the Map + +## Example + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index 6fef8da25aa..160fcb91ee7 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -24,34 +24,36 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Extract the values of the given `map` into an `ARRAY` of the corresponding type -`ARRAY<K> map_values(Map<K, V> map)` +## Syntax -Extracts the value of a given `map` into an `ARRAY` of the corresponding type. +```sql +MAP_VALUES(<map>) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<map>` | Input map content | -### Example +## Return Value + +Extract the values of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 8ffda7f1030..f19716c0dc1 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -24,34 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Constructs a `Map<K, V>` of a specific type using some set of key-value pairs -`MAP<K, V> map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +## Syntax -Construct a type-specific `Map<K, V>` using a set of key-value pairs. +```sql +MAP( <key1> , <value1> [, <key2>,<value2> ... ]) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `<key>` | Constructing the key of the map | +| `<value>` | Constructing the value of the map | -### Example +## Return Value + +Returns a specific type `Map<K, V>` constructed from a number of key-value pairs + +## Example ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org