cassandra2.1版终于出了稳定版-cassandra2.1.6版。照例把之前的功能在新版本上跑一跑。但是仍然遇到一个问题:

创建一个表


CREATE TABLE test (
a int,
b int,
c int,
d int,
PRIMARY KEY (a, b, c)
);

根据a=1 and b<6查询结果是:

select * from test where a=1 and b<6;

a | b | c | d —+—+—+— 1 | 3 | 1 | 2 1 | 3 | 2 | 2 1 | 3 | 4 | 2 1 | 3 | 5 | 2 1 | 4 | 4 | 2 1 | 5 | 5 | 2

(6 rows)

分页查询 第一页

select * from test where a=1 and b<6 limit 2;

a | b | c | d —+—+—+— 1 | 3 | 1 | 2 1 | 3 | 2 | 2

(2 rows)

第二页

select * from test where a=1 and b<6 and (b,c) > (3,2) limit 2;

a | b | c | d —+—+—+— 1 | 3 | 4 | 2 1 | 3 | 5 | 2

(2 rows) 第三页

select * from test where a=1 and b<6 and (b,c) > (3,5) limit 2;

a | b | c | d —+—+—+— 1 | 4 | 4 | 2 1 | 5 | 5 | 2

(2 rows)

问题是: 这种查询在2.0.8版本是可行的,但是到2.1.6版本就不行了。 当执行:

select * from test where a=1 and b<6 and (b,c) > (3,2) limit 2;

会得到这样一个错误:

InvalidRequest: code=2200 [Invalid query] message=“Column “b” cannot have both tuple-notation inequalities and single-column inequalities: (b, c) > (3, 2)”

作者建议我这样使用:

select * from test where a=1 and (b)<6 and (b,c) > (3,2) limit 2;

作者也认为b<6 应该和 (b)<6 等价的,否则很让人迷惑。

目前已经有可用补丁出来了,这不就2.1.7版本已经出来了,预计这个补丁会合到下一个2.1.8版本中吧。

地址:https://issues.apache.org/jira/browse/CASSANDRA-9606