插入clickhouse的某个字段是json,请问使用什么类型比较好处理?

提问者:帅平 问题分类:大数据
插入clickhouse的某个字段是json,请问使用什么类型比较好处理?
1 个回答
离不开天空的云
离不开天空的云
使用map类型即可,例如创建表:
CREATE TABLE test.test_local2 on cluster default_cluster (
    `id` UInt64,
    `data` Map(String, String),
) ENGINE = ReplicatedMergeTree()
partition by dt
order by id;
CREATE TABLE test.test_all2 on cluster default_cluster as test.test_local2 ENGINE = Distributed('default_cluster', 'test', 'test_local2', sipHash64(id));

clickhouse对于map类型的包容性比较好,查询的时候可以直接使用data[‘key’]的方式查询,例如:
select data['key'] from test.test_all2 limit 5
发布于:2个月前 (03-19) IP属地:未知
我来回答