Thanks Tristan and Sylvain, it all makes sense now. One follow up question regarding the composite column. It seems that for the where clause I can only restrict the query on the first composite column (friend_id, in my case). I understand it's determined by the underlining row storage structure. Is any plan to improve that to be able to search on the other composite columns if I don't care about the performance.
cqlsh:demo> select * from friends where source = 7; Bad Request: PRIMARY KEY part source cannot be restricted (preceding part status is either not restricted or by a non-EQ relation) Thanks. -Wei ________________________________ From: Tristan Seligmann <mithra...@mithrandi.net> To: user@cassandra.apache.org; Wei Zhu <wz1...@yahoo.com> Sent: Wednesday, October 31, 2012 10:47 AM Subject: Re: Create CF with composite column through CQL 3 On Wed, Oct 31, 2012 at 7:14 PM, Wei Zhu <wz1...@yahoo.com> wrote: > I try to use CQL3 to create CF with composite columns, > > CREATE TABLE Friends ( > ... user_id bigint, > ... friend_id bigint, > ... status int, > ... source int, > ... created timestamp, > ... lastupdated timestamp, > ... PRIMARY KEY (user_id, friend_id, status, source) > ... ); > > > When I check it with cli, the composite type is a bit odd, why it's defined > as Long, Int32, Int32, UTF8, is it supposed to be Long, Long, Int32, Int32? The first component of the PRIMARY KEY (user_id) is the row key: > Key Validation Class: org.apache.cassandra.db.marshal.LongType The rest of the components (friend_id, status, source) are part of the column name: > Columns sorted by: org.apache.cassandra.db.marshal.CompositeType( > org.apache.cassandra.db.marshal.LongType, > org.apache.cassandra.db.marshal.Int32Type, > org.apache.cassandra.db.marshal.Int32Type, and the final component of of the column name is the "CQL-level" column name: > org.apache.cassandra.db.marshal.UTF8Type) In this case, it will be "created" or "lastupdated" as those are the only columns not part of the PRIMARY KEY. -- mithrandi, i Ainil en-Balandor, a faer Ambar