我在Mac OS X上使用Datastax cassandra发行版(dsc-cassandra-1.2.6)。我想使用timeuuid类型,并正在尝试对它们进行查询。
这是我的表:
CREATE TABLE test_t (
canon_key text,
t timeuuid,
PRIMARY KEY (canon_key, t)
)
现在让我说我得到一排。
cqlsh:pagedb> select canon_key, t, dateOf(t), unixTimestampOf(t) from test_t where canon_key = 'xxx' and t >= minTimeuuid('2013-08-08 18:43:58-0700');
canon_key | t | dateOf(t) | unixTimestampOf(t)
-----------+--------------------------------------+--------------------------+--------------------
xxx | 287d3c30-0095-11e3-9268-a7d2e09193eb | 2013-08-08 18:43:58-0700 | 1376012638067
现在,我想删除这一行。我没有看到这样做的好方法,因为timeuuid类型没有相等运算符。
我添加的数据的性质使我(可能)甚至不介意这样做:
cqlsh:pagedb>从test_t中选择canon_key,t,dateOf(t),unixTimestampOf(t),其中canon_key ='xxx'和t> = minTimeuuid('2013-08-08 18:43:58-0700')和t< = maxTimeuuid ('2013-08-08 18:43:58-0700');
但是根据文档(http://cassandra.apache.org/doc/cql3/CQL.html#usingdates),这是行不通的。引述:“请注意,t> = maxTimeuuid('2013-01-01 00:05 + 0000')仍然不会选择在'2013-01-01 00:05 + 0000'生成的timeuuid,并且基本上等效to t> maxTimeuuid('2013-01-01 00:05 + 0000')。“。
那么..如何删除这一行?
答案 0 :(得分:5)
您的前提是错误的 - minTimeuuid
和maxTimeuuid
确实存在以允许在上对timeuuids进行相等操作,但这并不意味着不支持简单的相等:< / p>
cqlsh:foo> insert into test_t (canon_key, t) values ('k', now());
cqlsh:foo> select * from test_t;
canon_key | t
-----------+--------------------------------------
k | 27609890-0209-11e3-b862-59d5a2b25b8f
(1 rows)
cqlsh:foo> delete from test_t where canon_key = 'k' and t = 27609890-0209-11e3-b862-59d5a2b25b8f;
cqlsh:foo> select * from test_t;
(0 rows)