【发布时间】:2016-07-07 08:39:15
【问题描述】:
我有这张桌子:
CREATE TABLE mytablename (
name text,
typeid int,
activefrom timestamp,
status text,
PRIMARY KEY ((name), typeid, activefrom)
)
我想查询一个有效的时间戳范围,例如这里的一些查询:
- activefrom > '2000-01-02'
- activefrom > '2000-01-02' AND activefrom
我注意到它不像在 sql 中那样工作。
例如
name | typeid | activefrom | status
------+--------+--------------------------+--------------
dani | 99999 | 1970-01-26 00:00:00+0000 | OK
dani | 99999 | 1970-01-26 01:00:00+0000 | OK
dani | 99999 | 2070-01-26 00:00:00+0000 | OK
dani | 99999 | 1970-01-01 00:00:00+0000 | OK
查询:
select * from mytablename where name='dani' and typeid=99999 and activefrom > '2070-01-02 12:51:58+0000';
结果是这样的:
dani | 99999 | 2070-01-26 00:00:00+0000 | OK
dani | 99999 | 1970-01-01 00:00:00+0000 | OK
Cassandra 版本:
cqlsh 4.1.1 | Cassandra 2.1.13.1218 | CQL spec 3.1.1 | Thrift protocol 19.39.0
有什么建议吗? 谢谢
【问题讨论】:
-
你能显示你的确切查询吗?
-
是的,当然,我只是添加了它。
-
这听起来很奇怪。您使用的是哪个版本的 Cassandra?
-
cqlsh 4.1.1 |卡桑德拉 2.1.13.1218 | CQL 规范 3.1.1 | Thrift 协议 19.39.0
-
这是一个想法...尝试以下查询:
SELECT name, typeid, activefrom, blobasbigint(timestampasblob(activefrom)) FROM mytablename WHERE name='dani' and typeid=99999 and activefrom > '2070-01-02 12:51:58+0000';我很想知道您的 1970-01-01 时间戳转换为的 UNIX 时间戳。