0

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
Vinod Jayachandran
  • 3,726
  • 8
  • 51
  • 88

1 Answers1

0

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.

Community
  • 1
  • 1
xmas79
  • 5,060
  • 2
  • 14
  • 35