0
votes

In cassandra DB I am trying range query on partition key column of date type using token function, but I get incorrect results. I intend to get records after 2016-09-09, but I get records of 2016-09-07 as well.

Cassandra version : 2.1.8 CQL version : 3.0

Refer my query below and let me know if I am doing anything wrong

user@cqlsh:mydb> select updated_on_day,updated_on from sample_data  where token(updated_on_day) > token('2016-09-09')  and token(updated_on_day) < token('2016-11-11') limit 10;

 updated_on_day           | updated_on
--------------------------+--------------------------
 2016-09-14 00:00:00+0530 | 2016-09-14 11:53:03+0530
 2016-09-14 00:00:00+0530 | 2016-09-14 14:26:58+0530
 2016-09-14 00:00:00+0530 | 2016-09-14 15:30:48+0530
 2016-09-14 00:00:00+0530 | 2016-09-14 16:01:56+0530
 2016-09-07 00:00:00+0530 | 2016-09-07 12:36:36+0530
1
Why don't you use timeuuid? - questionaire
Thanks @AshrafulIslam That link explains it all. - Vinod Jayachandran

1 Answers

0
votes

Definitely, your partitions are ordered by their tokens, and unless you use a ByteOrderedPartitioner which preserves the order of the raw bytes of your partition key, their order can be assumed random.

Here's my recent answer to a similar question.