1
你好,我想查询定期发送警报的某些设备的数据。所以我想要一个时间系列。 我创建了这样一个表格:卡桑德拉时间序列查询
CREATE TABLE alerts_by_day (
day_of_year int,
year int,
alert_timestamp timestamp,
serial_number text,
alert_id uuid,
alert_type text,
PRIMARY KEY((day_of_year, year), serial_number, alert_timestamp, alert_type,alert_id)
) WITH CLUSTERING ORDER BY (serial_number DESC, alert_timestamp DESC, alert_type DESC);
现在,我想创建为了查询或物化视图能够通过一个时间范围来查询(即:从2015年11月29日至2016年1月20)和警报类型。所以我只想显示某种类型和时间范围的警报。我可以查询在一定时间范围:
Select * from alerts_by_day
where day_of_year IN (312,313)
and year IN (2016,2015)
and alert_timestamp < '2016-11-08 03:09:14-0800'
and alert_timestamp > '2016-11-07 23:13:28-0800'
,但我不能这样做:
Select * from alerts_by_day
where day_of_year IN (312,313)
and year IN (2016,2015)
and alert_timestamp < '2016-11-08 03:09:14-0800'
and alert_timestamp > '2016-11-07 23:13:28-0800'
and alert_type IN ('type1', 'type2')
因为我用的是不是alert_timestamp EQ的限制。
我怎么能实现我只看到类型1和类型2的警报?
这里是错误: 无法执行CQL脚本:聚类列ALERT_TYPE不能限制(precedign列alert_timestamp由非EQ-关系限制)
您使用哪个cassandra版本? – root545
我删除了我的答案。但你可以检查这个答案http://stackoverflow.com/questions/34422515/cassandra-error-clustering-column-cannot-be-restricted-preceding-column-is-re我短小你在做什么是不可能的 – root545