Skip to content

Commit

Permalink
docs: map type specific docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aceforeverd committed Apr 21, 2024
1 parent 6b52ee5 commit 98f52c3
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
29 changes: 29 additions & 0 deletions docs/en/openmldb_sql/data_types/composite_types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Composite data type

## MAP type

Represents values comprising a set of key-value pairs.

**Syntax**

```sql
MAP < KEY, VALUE >
```

**Example**

```sql
-- construct map value with map builtin function, each parameter is
-- key1, value1, key2, value2, ... respectively
select map (1, "12", 2, "100")
-- {1: "12", 2: "100"}

-- access map value with [] operator
select map (1, "12", 2, "100")[2]
-- "100"
```

**Limitations**

1. Generally not recommended to store a map value with too much key-value pairs, since it's a row-based storage module.
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.
3 changes: 2 additions & 1 deletion docs/en/openmldb_sql/data_types/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ Data Type

numeric_types
string_types
date_and_time_types
composite_types.md
date_and_time_types.md
28 changes: 28 additions & 0 deletions docs/zh/openmldb_sql/data_types/composite_types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 复合数据类型

## MAP 类型

包含 key-value pair 的 map 类型。

**Syntax**

```sql
MAP < KEY, VALUE >
```

**Example**

```sql
-- 使用 map function 构造 map 数据类型,参数 1-N 表示 key1, value1, key2, value2, ...
select map (1, "12", 2, "100")
-- {1: "12", 2: "100"}

-- 用 [] operator 抽取特定 key 的 value
select map (1, "12", 2, "100")[2]
-- "100"
```

**限制**

1. 由于采用行存储形式,不建议表的 MAP 类型存储 key-value pair 特别多的情况,否则可能导致性能问题。
2. map 数据类型不支持作为索引的 key 或 ts 列,无法对 map 列特定 key 做查询优化。
1 change: 1 addition & 0 deletions docs/zh/openmldb_sql/data_types/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
numeric_types
string_types
date_and_time_types
compsite_types

0 comments on commit 98f52c3

Please sign in to comment.