Skip to content

Commit

Permalink
doc: Add support for map and make_map functions (#11799)
Browse files Browse the repository at this point in the history
* doc: Add support for `map` and `make_map` functions

* chore: Add example for MAP
  • Loading branch information
Weijun-H committed Aug 5, 2024
1 parent 0417e54 commit f56a2ef
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions docs/source/user-guide/sql/scalar_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3636,6 +3636,70 @@ Unwraps struct fields into columns.
+-----------------------+-----------------------+
```

## Map Functions

- [map](#map)
- [make_map](#make_map)

### `map`

Returns an Arrow map with the specified key-value pairs.

```
map(key, value)
map(key: value)
```

#### Arguments

- **key**: Expression to be used for key.
Can be a constant, column, or function, any combination of arithmetic or
string operators, or a named expression of previous listed.
- **value**: Expression to be used for value.
Can be a constant, column, or function, any combination of arithmetic or
string operators, or a named expression of previous listed.

#### Example

```
SELECT MAP(['POST', 'HEAD', 'PATCH'], [41, 33, null]);
----
{POST: 41, HEAD: 33, PATCH: }
SELECT MAP([[1,2], [3,4]], ['a', 'b']);
----
{[1, 2]: a, [3, 4]: b}
SELECT MAP { 'a': 1, 'b': 2 };
----
{a: 1, b: 2}
```

### `make_map`

Returns an Arrow map with the specified key-value pairs.

```
make_map(key_1, value_1, ..., key_n, value_n)
```

#### Arguments

- **key_n**: Expression to be used for key.
Can be a constant, column, or function, any combination of arithmetic or
string operators, or a named expression of previous listed.
- **value_n**: Expression to be used for value.
Can be a constant, column, or function, any combination of arithmetic or
string operators, or a named expression of previous listed.

#### Example

```
SELECT MAKE_MAP('POST', 41, 'HEAD', 33, 'PATCH', null);
----
{POST: 41, HEAD: 33, PATCH: }
```

## Hashing Functions

- [digest](#digest)
Expand Down

0 comments on commit f56a2ef

Please sign in to comment.