Cassandra-CQl : Change Clustering order for Created Column Family

cassandra, cql

Solution

Changing the clustering order would require rewriting all your data on disk in a different order. The standard way to do this is to leverage Spark with the Cassandra Spark Connector: https://github.com/datastax/spark-cassandra-connector

Alternatively, if you're early in your dev process or it's a relatively small amount of data, you can use the bulk loader to throw it into a new table: https://docs.datastax.com/en/dsbulk/doc/

Problem

I know that I can define clustering order when I create a table by cql as code below: ``` create table test( id int, time timestamp, value text, primary key(id,time)) with clustering order by (time desc) ``` but I want change the clustering for table test after its creation with alter: ``` alter table test with clustering order by (item asc) ``` but I got error by that. Thanks for any help.

Original source