Is is possible to have a column as a partition and clustering key? For example,
Create table citylist2 ( city varchar, loc list, pop int, zip varchar, state varchar, primary key (city,city,zip)) WITH CLUSTERING ORDER BY (city ASC, zip DESC);
results in:
InvalidRequest: Error from server: code=2200 [Invalid query] message="Unknown definition city referenced in PRIMARY KEY"
I might be doing this wrong, but can anyone tell me if it is possible to have the column "city" as the partition and clustering key and how to do so if it is possible?
答案 0 :(得分:1)
The issue is likely that you are trying to reference city twice in the Primary key definition.
答案 1 :(得分:1)
As far as I understand, this is not possible. The partition key splits your data over partitions, and the cluster key will then sort the data within each partition. So it doesn't make sense to have a partition key which is also a clustering key. You may need to rethink your data model for what it is you are attempting.
答案 2 :(得分:1)
Create table citylist2 ( city varchar,citycopy varchar, loc list, pop int, zip varchar, state varchar, primary key (city,citycopy,zip)) WITH CLUSTERING ORDER BY (citycopy ASC, zip DESC);
如果您确实想做自己想做的事情-将相同的数据复制到两列中,则可以使用以上内容。
如果您可以提供更多有关为什么要使用与分区和群集相同的数据的详细信息,答案可能会有所改变。