Reputation: 474
I am using below query to create table
CREATE table audit_log_keyspace.rules_engine_audit_logs
(
id timeuuid,
facts map<text, text>,
result_set map<text, text>,
async_id uuid,
rule_set_version_id int,
inserted_at timestamp,
created_at timestamp,
PRIMARY KEY (id)
) WITH CLUSTERING ORDER BY (id DESC);
Am I missing something in this create table command. I am getting
Only clustering key columns can be defined in CLUSTERING ORDER directive
I found similar questions but didn't find the solution from that question.
Upvotes: 1
Views: 54
Reputation: 87119
Primary key in Cassandra consists of two objects:
In your case, your primary key consists of one column, and this is by default is partition key, so you don't have clustering columns that you can define in the CLUSTERING ORDER BY
clause. If you want to achieve "global sorting" of the data by id
column - it's impossible, as the value is partition key is hashed, and distributed between servers, for example, 5
could be on one server, and 6
- on another, etc.
P.S. I recommend to grab free copy of the "Cassandra: The Definitive Guide, 3rd edition" book from the DataStax's site - it will provide you the necessary information about data modeling, querying the data, etc.
Upvotes: 1