Qiu Zhida created CASSANDRA-12223: ------------------------------------- Summary: SASI Indexes querying incorrectly return 0 rows Key: CASSANDRA-12223 URL: https://issues.apache.org/jira/browse/CASSANDRA-12223 Project: Cassandra Issue Type: Bug Components: sasi Environment: Windows, DataStax Distribution Reporter: Qiu Zhida Fix For: 3.7
I just started working with the SASI index on Cassandra 3.7.0 and I encountered a problem which as I suspected was a bug. I had hardly tracked down the situation in which the bug showed up, here is what I found: When querying with a SASI index, *it may incorrectly return 0 rows*, and changing a little conditions, it works again, like the following CQL code: {code:title=CQL|borderStyle=solid} CREATE TABLE IF NOT EXISTS roles ( name text, a int, b int, PRIMARY KEY ((name, a), b) ) WITH CLUSTERING ORDER BY (b DESC); insert into roles (name,a,b) values ('Joe',1,1); insert into roles (name,a,b) values ('Joe',2,2); insert into roles (name,a,b) values ('Joe',3,3); insert into roles (name,a,b) values ('Joe',4,4); CREATE TABLE IF NOT EXISTS roles2 ( name text, a int, b int, PRIMARY KEY ((name, a), b) ) WITH CLUSTERING ORDER BY (b ASC); insert into roles2 (name,a,b) values ('Joe',1,1); insert into roles2 (name,a,b) values ('Joe',2,2); insert into roles2 (name,a,b) values ('Joe',3,3); insert into roles2 (name,a,b) values ('Joe',4,4); CREATE CUSTOM INDEX ON roles (b) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = { 'mode': 'SPARSE' }; CREATE CUSTOM INDEX ON roles2 (b) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = { 'mode': 'SPARSE' }; {code} Noticing that I only change table *roles2* from table *roles*'s '*CLUSTERING ORDER BY (b DESC)*' into '*CLUSTERING ORDER BY (b ASC)*'. When querying with statement +select * from roles2 where b<3+, the rusult is two rows: {code:title=CQL|borderStyle=solid} name | a | b ------+---+--- Joe | 1 | 1 Joe | 2 | 2 (2 rows) {code} However, if querying with +select * from roles where b<3+, it returned no rows at all: {code:title=CQL|borderStyle=solid} name | a | b ------+---+--- (0 rows) {code} This is not the only situation where the bug would show up, one time I created a SASI index with specific name like 'end_idx' on column 'end', the bug showed up, when I didn't specify the index name, it gone. -- This message was sent by Atlassian JIRA (v6.3.4#6332)