1
votes

Here is my schema:

CREATE TABLE test (
 x int,
 y int,
 z int,
 PRIMARY KEY (x)
);

If I run follow query:

select * from test where x in (1,1,1);

Cassandra will return 3 duplicate rows for me. It seems like Cassandra execute the prepared statement to the same partition for 3 times in the query trace.

Does this the default behaviour for Cassandra.

Environment: [cqlsh 5.0.1 | Cassandra 2.1.9 | CQL spec 3.2.0 | Native protocol v3]

1

1 Answers

2
votes

It seems like Cassandra execute the prepared statement to the same partition for 3 times in the query trace.

Yes, that is exactly how the CQL IN statement behaves. This issue caused enough confusion with Cassandra that it was addressed in time for 2.2.0. If you try this in Cassandra 2.2.0, you will see that IN now functions as you would expect.

aploetz@stackoverflow> SELECT * FROM timestamptest WHERe userid IN ('b','b');

 userid | activetime               | value
--------------------------------------------
      b | 2015-09-03 14:16:04-0500 | value3

(1 rows)
aploetz@cqlsh:stackoverflow> SELECT release_version FROM system.local;

 release_version
-----------------
           2.2.0

(1 rows)