0

Im trying to create a new table using the command:

create table schema2(city varchar, loc list, pop int, zip varchar,state varchar, primary key (city, zip)) WITH CLUSTERING ORDER BY (city ASC, zip DESC);

But I get the error:

InvalidRequest: Error from server: code=2200 [Invalid query] message="Only clustering key columns can be defined in CLUSTERING ORDER directive"

I specified the primary keys I want and I did the clustering order by with only primary keys but it still gets and error. How do I fix this?

1 Answer 1

0

create table schema2(city varchar, loc list, pop int, zip varchar,state varchar, primary key (city, zip)) WITH CLUSTERING ORDER BY (city ASC, zip DESC);

In this definition (city,zip) is called PRIMARY KEY, city is called partition key and zip is called clustering key. Data is distributed among all the nodes based on the partition key. Data is ordered within the partition based on the clustering key. So, you cannot perform ordering on the city. The error which you mentioned clearly states it. If you skip city in your clustering order you DDL will be accepted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.