先照着把表做一个:Map类型:ClickHouse中对动态字段的支持 - 简书 (jianshu.com)
- CREATE TABLE user_game_play
-
- (
-
- mid UInt64,
-
- buvid String,
-
- game_play_duration Map(String, UInt32),
-
- log_date String
-
- )
-
- ENGINE=MergeTree()
-
- PARTITION BY log_date
-
- ORDER BY mid;
insert into user_game_play values (1, '123', map('wzry',3600, 'FGO', 1800), '2021-11-14');
SELECT game_play_duration['wzry'] AS duration FROM user_game_play
结果
- ┌─duration─┐
- │ 3600 │
- └──────────┘
从GitHub clickhouse上的回复上知道,map是根据线性数组实现的,性能上没有array强。clickhouse-issues@23299
函数
tuple-map-functions | ClickHouse Docs