Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

docs: add map and array functions #1644

Merged
merged 5 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: ARRAYS_ZIP
---
import FunctionDescription from '@site/src/components/FunctionDescription';

<FunctionDescription description="Introduced or updated: v1.2.690"/>

Merges multiple arrays into a single array tuple.

## Syntax

```sql
ARRAYS_ZIP( <array1> [, ...] )
```

## Arguments

| Arguments | Description |
|------------|-------------------|
| `<arrayN>` | 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')] │
└────────────────────────────────────────┘
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: ST_GEOMETRYFROMTEXT
---

Alias for [ST_GEOMETRYFROMWKT](st-geometryfromwkt.md).
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ST_GEOMETRYFROMWKT(<string>, [<srid>])
- [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

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ Returns an existing MAP with one or more keys removed.

```sql
MAP_DELETE( <map>, <key1> [, <key2>, ... ] )
MAP_DELETE( <map>, <array> )
```

## Arguments

| Arguments | Description |
|-----------|----------------------------------------------|
| `<map>` | The MAP that contains the KEY to remove. |
| `<keyN>` | The KEY to be omitted from the returned MAP. |
| Arguments | Description |
|-----------|--------------------------------------------------------|
| `<map>` | The MAP that contains the KEY to remove. |
| `<keyN>` | The KEYs to be omitted from the returned MAP. |
| `<array>` | 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.
Expand All @@ -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} │
└─────────────────────────────────────────────┘
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: MAP_INSERT
---
import FunctionDescription from '@site/src/components/FunctionDescription';

<FunctionDescription description="Introduced or updated: v1.2.654"/>

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( <map>, <key>, <value> [, <updateFlag> ] )
```

## Arguments

| Arguments | Description |
|----------------|----------------------------------------------------------------------------------------------|
| `<map>` | The input MAP. |
| `<key>` | The new key to insert into the MAP. |
| `<value>` | The new value to insert into the MAP. |
| `<updateFlag>` | The boolean flag indicates whether an existing key can be overwritten. The 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} │
└───────────────────────────────────────────────┘
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: MAP_PICK
---
import FunctionDescription from '@site/src/components/FunctionDescription';

<FunctionDescription description="Introduced or updated: v1.2.654"/>

Returns a new MAP containing the specified key-value pairs from an existing MAP.

## Syntax

```sql
MAP_PICK( <map>, <key1> [, <key2>, ... ] )
MAP_PICK( <map>, <array> )
```

## Arguments

| Arguments | Description |
|-----------|-------------------------------------------------------- |
| `<map>` | The input MAP. |
| `<keyN>` | The KEYs to be included from the returned MAP. |
| `<array>` | 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} │
└───────────────────────────────────────────┘
```
Loading