如何从分布式中获取数据 table
How to get data from distributed table
如果我有一个 table,更新了哪个结构(即最近更新后的 system.query_log),但不知何故分布式 "view" 仍然有旧结构,我如何查询数据来自整个集群的新列?
我的意思是:
如果您已经分发 table,可以通过以下方式轻松完成:
select count(1) from distributed_query_log where event_date = '2019-01-24'
但是 select Settings.names, Settings.values from distributed_query_log where event_date = '2019-01-24' limit 1\G
会失败,因为它没有那些字段,当 system.query_log 有:
select Settings.names, Settings.values from system.query_log where event_date = '2019-01-24' limit 1\G
在 Clickhouse 版本 1.1.54362 中添加了功能 cluster
。
因此,您可以通过以下方式完成:
select Settings.names, Settings.values from cluster('CLUSTER_TITLE', 'system.query_log') where event_date = '2019-01-24' limit 1\G
其中 CLUSTER_TITLE
- 您的集群的标题。
一般情况下:更改基础 table 后,您需要重新创建(或更改)分布式 table。
如果我有一个 table,更新了哪个结构(即最近更新后的 system.query_log),但不知何故分布式 "view" 仍然有旧结构,我如何查询数据来自整个集群的新列?
我的意思是:
如果您已经分发 table,可以通过以下方式轻松完成:
select count(1) from distributed_query_log where event_date = '2019-01-24'
但是 select Settings.names, Settings.values from distributed_query_log where event_date = '2019-01-24' limit 1\G
会失败,因为它没有那些字段,当 system.query_log 有:
select Settings.names, Settings.values from system.query_log where event_date = '2019-01-24' limit 1\G
在 Clickhouse 版本 1.1.54362 中添加了功能 cluster
。
因此,您可以通过以下方式完成:
select Settings.names, Settings.values from cluster('CLUSTER_TITLE', 'system.query_log') where event_date = '2019-01-24' limit 1\G
其中 CLUSTER_TITLE
- 您的集群的标题。
一般情况下:更改基础 table 后,您需要重新创建(或更改)分布式 table。