Kassandra: only EQ and IN relationships are supported on a partition key (unless you use the token () function)

Table:

CREATE TABLE TEST_PAYLOAD ( TIME_STAMP timestamp, TYPE text, PRIMARY KEY (TIME_STAMP) ); time_stamp | type --------------------------+---------- 2013-05-15 00:00:00-0700 | sometext 2013-05-16 00:00:00-0700 | sometext 2013-05-17 00:00:00-0700 | sometext SELECT * FROM TEST_PAYLOAD WHERE TIME_STAMP>='2013-05-15 00:00:00-0700'; code=2200 [Invalid query] message="Only EQ and IN relation are supported on the partition key (unless you use the token() function)" 

it does not work for> or any range selection, while it works = as the default index, it has only one primary key, there is no section key. Why is he asking for a token ().

i I would like to get a relative range, it can only be a date or a date with time when a specific timestamp is not in db.

+5
source share
1 answer

I think you are a little confused in the terminology of Cassandra.

Please contact here

partition key: The first column declared in the PRIMARY KEY definition

those. when creating a table like this

 CREATE TABLE table { key1, key2, key3, PRIMARY KEY (key1, key2, key3) } 

key1 is called the partition key and key2 , key3 are called clusters .

In your case, you do not have clustering keys, so the only primary key that you declared is the partition key.

In addition, range queries (<,>) must be performed using the clustering keys.

If you have no other candidates for the primary key, I think you should redo your table as follows

 CREATE TABLE TEST_PAYLOAD ( BUCKET varchar, TIME_STAMP timestamp, TYPE text, PRIMARY KEY (BUCKET, TIME_STAMP) ); 

For BUCKET you can specify a combination of year or year and month. Thus, your keys will look like 2013, 2014, 06-2014, 10-2014, etc.

Thus, when prompted, go to the desired bucket and scan the range, for example TIME_STAMP> = '2013-05-15 00: 00: 00-0700'

+14
source

Source: https://habr.com/ru/post/1208863/


All Articles