-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b52ee5
commit 98f52c3
Showing
4 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ Data Type | |
|
||
numeric_types | ||
string_types | ||
date_and_time_types | ||
composite_types.md | ||
date_and_time_types.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 做查询优化。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
numeric_types | ||
string_types | ||
date_and_time_types | ||
compsite_types |