Reputation: 183
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?
Upvotes: 0
Views: 130
Reputation: 163
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.
Upvotes: 0