Search code examples
create-tablecqlshcassandra-2.1

'create table' event ... with Apache Cassandra


I am trying to run a Cassandra server. For that i just followed the tutorial on that page (http://www.opencredo.com/2014/10/23/spring-data-cassandra-overview/).

I am stuck on the step: Setting up Cassandra

When i try to create a table as described in tutorial i got an ErrorMessage code=2000.

cqlsh:events> CREATE TABLE event ( 
  type text, bucket text, id timeuuid, tags set, 
  PRIMARY KEY (( type, bucket), id)) WITH CLUSTERING ORDER BY (id DESC);

ErrorMessage code=2000 [Syntax error in CQL query] message="line 1:66
mismatched input ',' expecting '<' (..., id timeuuid, tags set[,] PRIMARY...)"

After intensive research I still don't know what the problem here is, does anyone have a clue what a problem could be here?

My version is:

[cqlsh 5.0.1 | Cassandra 2.1.2 | CQL spec 3.2.0 | Native protocol v3]

Solution

  • You have to specify the type of the set like :

    CREATE TABLE event (
      type text,
      bucket text,
      id timeuuid,
      tags set<text>,
      PRIMARY KEY ((type, bucket), id)
    ) WITH CLUSTERING ORDER BY (id DESC);
    

    For more information see this link