How to perform ordering in cassandra

525 views Asked by At

I have table in Cassandra which includes a field id. I have set that field as partition key. Now I want to query that table order by id. How can I select all rows from that table in the order of id using Cql?

1

There are 1 answers

0
Arun Joy Thekkiniyath On

In Cassandra you cannot order by partition key. You can only order within a partition key

Error from cql:

code=2200 [Invalid query] message="Order by is currently only supported on the clustered 
columns of the PRIMARY KEY, got id"

You will have to create a table with id as clustering key and then order by id.