From 2ba2dcf3352b4f14e1c0eb91f322dc855d343fe5 Mon Sep 17 00:00:00 2001 From: baishen Date: Tue, 11 Feb 2025 15:44:50 +0800 Subject: [PATCH 1/2] docs: add map and array functions --- .../00-array-functions/arrays-zip.md | 39 +++++++++++++++ .../st-geometryfromtext.md | 5 ++ .../st-geomtryfromtext.md | 5 -- .../10-map-functions/map-delete.md | 17 +++++-- .../10-map-functions/map-insert.md | 45 +++++++++++++++++ .../10-map-functions/map-pick.md | 50 +++++++++++++++++++ 6 files changed, 152 insertions(+), 9 deletions(-) create mode 100644 docs/en/sql-reference/20-sql-functions/00-array-functions/arrays-zip.md create mode 100644 docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geometryfromtext.md delete mode 100644 docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geomtryfromtext.md create mode 100644 docs/en/sql-reference/20-sql-functions/10-map-functions/map-insert.md create mode 100644 docs/en/sql-reference/20-sql-functions/10-map-functions/map-pick.md diff --git a/docs/en/sql-reference/20-sql-functions/00-array-functions/arrays-zip.md b/docs/en/sql-reference/20-sql-functions/00-array-functions/arrays-zip.md new file mode 100644 index 0000000000..bd1021d38d --- /dev/null +++ b/docs/en/sql-reference/20-sql-functions/00-array-functions/arrays-zip.md @@ -0,0 +1,39 @@ +--- +title: ARRAYS_ZIP +--- +import FunctionDescription from '@site/src/components/FunctionDescription'; + + + +Merge multiple arrays into a single array tuple. + +## Syntax + +```sql +ARRAYS_ZIP( [, ...] ) +``` + +## Arguments + +| Arguments | Description | +|------------|-------------------| +| `` | The input ARRAYs. | + +:::note +- The length of each array must be the same. +::: + +## Return Type + +Array(Tuple). + +## Examples + +```sql +SELECT ARRAYS_ZIP([1, 2, 3], ['a', 'b', 'c']); +┌────────────────────────────────────────┐ +│ arrays_zip([1, 2, 3], ['a', 'b', 'c']) │ +├────────────────────────────────────────┤ +│ [(1,'a'),(2,'b'),(3,'c')] │ +└────────────────────────────────────────┘ +``` diff --git a/docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geometryfromtext.md b/docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geometryfromtext.md new file mode 100644 index 0000000000..77469fb7bc --- /dev/null +++ b/docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geometryfromtext.md @@ -0,0 +1,5 @@ +--- +title: ST_GEOMETRYFROMTEXT +--- + +Alias for [ST_GEOMETRYFROMWKT](st-geometryfromwkt.md). diff --git a/docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geomtryfromtext.md b/docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geomtryfromtext.md deleted file mode 100644 index f2aff5819d..0000000000 --- a/docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geomtryfromtext.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: ST_GEOTRYMFROMTEXT ---- - -Alias for [ST_GEOMTRYFROMWKT](st-geometryfromwkt.md). diff --git a/docs/en/sql-reference/20-sql-functions/10-map-functions/map-delete.md b/docs/en/sql-reference/20-sql-functions/10-map-functions/map-delete.md index f3e91c934f..cfa736f966 100644 --- a/docs/en/sql-reference/20-sql-functions/10-map-functions/map-delete.md +++ b/docs/en/sql-reference/20-sql-functions/10-map-functions/map-delete.md @@ -11,14 +11,16 @@ Returns an existing MAP with one or more keys removed. ```sql MAP_DELETE( , [, , ... ] ) +MAP_DELETE( , ) ``` ## Arguments -| Arguments | Description | -|-----------|----------------------------------------------| -| `` | The MAP that contains the KEY to remove. | -| `` | The KEY to be omitted from the returned MAP. | +| Arguments | Description | +|-----------|--------------------------------------------------------| +| `` | The MAP that contains the KEY to remove. | +| `` | The KEYs to be omitted from the returned MAP. | +| `` | The Array of KEYs to be omitted from the returned MAP. | :::note - The types of the key expressions and the keys in the map must be the same. @@ -38,4 +40,11 @@ SELECT MAP_DELETE({'a':1,'b':2,'c':3}, 'a', 'c'); ├───────────────────────────────────────────┤ │ {'b':2} │ └───────────────────────────────────────────┘ + +SELECT MAP_DELETE({'a':1,'b':2,'c':3}, ['a', 'b']); +┌─────────────────────────────────────────────┐ +│ map_delete({'a':1,'b':2,'c':3}, ['a', 'b']) │ +├─────────────────────────────────────────────┤ +│ {'c':3} │ +└─────────────────────────────────────────────┘ ``` diff --git a/docs/en/sql-reference/20-sql-functions/10-map-functions/map-insert.md b/docs/en/sql-reference/20-sql-functions/10-map-functions/map-insert.md new file mode 100644 index 0000000000..5de3e0627f --- /dev/null +++ b/docs/en/sql-reference/20-sql-functions/10-map-functions/map-insert.md @@ -0,0 +1,45 @@ +--- +title: MAP_INSERT +--- +import FunctionDescription from '@site/src/components/FunctionDescription'; + + + +Returns a new MAP consisting of the input MAP with a new key-value pair inserted (an existing key updated with a new value). + +## Syntax + +```sql +MAP_INSERT( , , [, ] ) +``` + +## Arguments + +| Arguments | Description | +|----------------|--------------------------------------------------------------------------------------------------| +| `` | The input MAP. | +| `` | The new key to insert into the MAP. | +| `` | The new value to insert into the MAP. | +| `` | The boolean flag identifies whether can overwrite the key that already exists. default is FALSE. | + +## Return Type + +Map. + +## Examples + +```sql +SELECT MAP_INSERT({'a':1,'b':2,'c':3}, 'd', 4); +┌─────────────────────────────────────────┐ +│ map_insert({'a':1,'b':2,'c':3}, 'd', 4) │ +├─────────────────────────────────────────┤ +│ {'a':1,'b':2,'c':3,'d':4} │ +└─────────────────────────────────────────┘ + +SELECT MAP_INSERT({'a':1,'b':2,'c':3}, 'a', 5, true); +┌───────────────────────────────────────────────┐ +│ map_insert({'a':1,'b':2,'c':3}, 'a', 5, TRUE) │ +├───────────────────────────────────────────────┤ +│ {'a':5,'b':2,'c':3} │ +└───────────────────────────────────────────────┘ +``` diff --git a/docs/en/sql-reference/20-sql-functions/10-map-functions/map-pick.md b/docs/en/sql-reference/20-sql-functions/10-map-functions/map-pick.md new file mode 100644 index 0000000000..69cd50cca2 --- /dev/null +++ b/docs/en/sql-reference/20-sql-functions/10-map-functions/map-pick.md @@ -0,0 +1,50 @@ +--- +title: MAP_PICK +--- +import FunctionDescription from '@site/src/components/FunctionDescription'; + + + +Returns a new MAP containing the specified key-value pairs from an existing MAP. + +## Syntax + +```sql +MAP_PICK( , [, , ... ] ) +MAP_PICK( , ) +``` + +## Arguments + +| Arguments | Description | +|-----------|-------------------------------------------------------- | +| `` | The input MAP. | +| `` | The KEYs to be included from the returned MAP. | +| `` | The Array of KEYs to be included from the returned MAP. | + +:::note +- The types of the key expressions and the keys in the map must be the same. +- Key values not found in the map will be ignored. +::: + +## Return Type + +Map. + +## Examples + +```sql +SELECT MAP_PICK({'a':1,'b':2,'c':3}, 'a', 'c'); +┌─────────────────────────────────────────┐ +│ map_pick({'a':1,'b':2,'c':3}, 'a', 'c') │ +├─────────────────────────────────────────┤ +│ {'a':1,'c':3} │ +└─────────────────────────────────────────┘ + +SELECT MAP_PICK({'a':1,'b':2,'c':3}, ['a', 'b']); +┌───────────────────────────────────────────┐ +│ map_pick({'a':1,'b':2,'c':3}, ['a', 'b']) │ +├───────────────────────────────────────────┤ +│ {'a':1,'b':2} │ +└───────────────────────────────────────────┘ +``` From 9bb78fc7b847152fd8187a78fbcbc441a375b2dd Mon Sep 17 00:00:00 2001 From: baishen Date: Wed, 12 Feb 2025 11:33:03 +0800 Subject: [PATCH 2/2] fix --- .../00-array-functions/arrays-zip.md | 2 +- .../09-geometry-functions/st-geometryfromwkt.md | 2 +- .../20-sql-functions/10-map-functions/map-insert.md | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/en/sql-reference/20-sql-functions/00-array-functions/arrays-zip.md b/docs/en/sql-reference/20-sql-functions/00-array-functions/arrays-zip.md index bd1021d38d..28e5a6683f 100644 --- a/docs/en/sql-reference/20-sql-functions/00-array-functions/arrays-zip.md +++ b/docs/en/sql-reference/20-sql-functions/00-array-functions/arrays-zip.md @@ -5,7 +5,7 @@ import FunctionDescription from '@site/src/components/FunctionDescription'; -Merge multiple arrays into a single array tuple. +Merges multiple arrays into a single array tuple. ## Syntax diff --git a/docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geometryfromwkt.md b/docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geometryfromwkt.md index a9c965cb8a..398690f0c9 100644 --- a/docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geometryfromwkt.md +++ b/docs/en/sql-reference/20-sql-functions/09-geometry-functions/st-geometryfromwkt.md @@ -19,7 +19,7 @@ ST_GEOMETRYFROMWKT(, []) - [ST_GEOMETRYFROMEWKT](st-geometryfromewkt.md) - [ST_GEOMFROMEWKT](st-geomfromewkt.md) - [ST_GEOMFROMTEXT](st-geomfromtext.md) -- [ST_GEOMTRYFROMTEXT](st-geomtryfromtext.md) +- [ST_GEOMETRYFROMTEXT](st-geometryfromtext.md) ## Arguments diff --git a/docs/en/sql-reference/20-sql-functions/10-map-functions/map-insert.md b/docs/en/sql-reference/20-sql-functions/10-map-functions/map-insert.md index 5de3e0627f..40133dfcbf 100644 --- a/docs/en/sql-reference/20-sql-functions/10-map-functions/map-insert.md +++ b/docs/en/sql-reference/20-sql-functions/10-map-functions/map-insert.md @@ -15,12 +15,12 @@ MAP_INSERT( , , [, ] ) ## Arguments -| Arguments | Description | -|----------------|--------------------------------------------------------------------------------------------------| -| `` | The input MAP. | -| `` | The new key to insert into the MAP. | -| `` | The new value to insert into the MAP. | -| `` | The boolean flag identifies whether can overwrite the key that already exists. default is FALSE. | +| Arguments | Description | +|----------------|----------------------------------------------------------------------------------------------| +| `` | The input MAP. | +| `` | The new key to insert into the MAP. | +| `` | The new value to insert into the MAP. | +| `` | The boolean flag indicates whether an existing key can be overwritten. The default is FALSE. | ## Return Type