CQL:基于日期和时间的查询?

时间:2014-10-26 15:33:35

标签: cassandra cql

假设我有一个表定义为:

CREATE TABLE events2 (
  homeid int,
  stamp timestamp,
  msec int,
  event int,
  sensor text,
  sequence int,
  PRIMARY KEY ((homeid), stamp, msec)) 

当我(尝试)根据日期/时间搜索时,我得到:

cqlsh:nyce> select count(*) from events2 where homeid = 165 and stamp > "2014-10-26 00:00:00-0700";
Bad Request: line 1:60 no viable alternative at input '2014-10-26 00:00:00-0700'

有没有办法让这样的查询成为可能?我应该使用 TimeUUID 吗?

1 个答案:

答案 0 :(得分:2)

查询的问题是条件必须是相等的条件。

select count(*) from events2 where homeid = 165 and stamp >='2014-10-26 00:00:00-0700';

返回:

 count
-------
     3

更正,正如布莱斯所说=没问题。这是引起问题的双引号。只需使用单引号:

select count(*) from events2 where homeid = 165 and stamp > '2014-10-26 00:00:00-0700';