Skip to content

Commit 70966f0

Browse files
authored
docs: map type specific docs (#3886)
1 parent 34a5f05 commit 70966f0

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Composite data type
2+
3+
## MAP type
4+
5+
Represents values comprising a set of key-value pairs.
6+
7+
**Syntax**
8+
9+
```sql
10+
MAP < KEY, VALUE >
11+
```
12+
13+
**Example**
14+
15+
```sql
16+
-- construct map value with map builtin function, each parameter is
17+
-- key1, value1, key2, value2, ... respectively
18+
select map (1, "12", 2, "100")
19+
-- {1: "12", 2: "100"}
20+
21+
-- access map value with [] operator
22+
select map (1, "12", 2, "100")[2]
23+
-- "100"
24+
```
25+
26+
**Limitations**
27+
28+
1. Generally not recommended to store a map value with too much key-value pairs, since it's a row-based storage model.
29+
2. Map data type can not used as the key or ts column of table index, queries can not be optimized based on specific key value inside a map column neither.
30+
3. Query a key-value in a map takes `O(n)` complexity at most.

docs/en/openmldb_sql/data_types/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ Data Type
88

99
numeric_types
1010
string_types
11+
composite_types
1112
date_and_time_types
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# 复合数据类型
2+
3+
## MAP 类型
4+
5+
包含 key-value pair 的 map 类型。
6+
7+
**Syntax**
8+
9+
```sql
10+
MAP < KEY, VALUE >
11+
```
12+
13+
**Example**
14+
15+
```sql
16+
-- 使用 map function 构造 map 数据类型,参数 1-N 表示 key1, value1, key2, value2, ...
17+
select map (1, "12", 2, "100")
18+
-- {1: "12", 2: "100"}
19+
20+
-- 用 [] operator 抽取特定 key 的 value
21+
select map (1, "12", 2, "100")[2]
22+
-- "100"
23+
```
24+
25+
**限制**
26+
27+
1. 由于采用行存储形式,不建议表的 MAP 类型存储 key-value pair 特别多的情况,否则可能导致性能问题。
28+
2. map 数据类型不支持作为索引的 key 或 ts 列,无法对 map 列特定 key 做查询优化。
29+
3. map key-value 查询最多消耗 `O(n)` 复杂度

docs/zh/openmldb_sql/data_types/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
numeric_types
1010
string_types
1111
date_and_time_types
12+
composite_types

0 commit comments

Comments
 (0)