Search code examples
cassandracql3datastax-enterprise

CREATE TABLE failing (wrong CQL version)


Creating tables failing with inet, multiple primary keys, and collections. Syntax was correct.

Error messages don't make sense with the primary key (unmatched parens). remove that, I learned that inet won't work except in some cases.

Anything I'm doing wrong, or not understanding about using CQL3 (interfaces or syntax)?

CREATE TABLE session (
  'user_id' bigint,
  'admin_id' bigint,
  'session_id' varchar,
  'cache' text ,
  'created' timestamp ,
  'hits' list<timestamp>, 
  'ip' inet  , 
  PRIMARY KEY ( 'session_id' , 'user_id' )  
  );

The following also fails

CREATE TABLE 'session' (
  'user_id' bigint,
  'session_id' varchar,
  PRIMARY KEY ( 'session_id' , 'user_id' )  
  );

This works

CREATE TABLE 'session' (
  'user_id' bigint,
  'session_id' varchar PRIMARY KEY 
  );

The clue

>help TYPES

    CQL types recognized by this version of cqlsh:

      ascii
      bigint
      blob
      boolean
      counter
      decimal
      double
      float
      int
      text
      timestamp
      uuid
      varchar
      varint

DSE 3.0.x

[EDIT] - turns out DSE has Cassandra 1.1.x installed.


Solution

  • TL;DR: Collections (part of CQL3) not available yet in DSE 3.0.x

    Also worth noting, but unrelated to my issue:

    Even in Datastax community edition - one needs to activate CQL3. The documentation says it should be activated by default in cqlsh

    http://www.datastax.com/docs/1.2/cql_cli/using_cql

    "Activating CQL 3 You activate the CQL mode in one of these ways:

    • Use the DataStax Java Driver to activate CQL through the
    • native/binary protocol. Start cqlsh, a Python-based command-line client.
    • Use the set_sql_version Thrift method.
    • Specify the desired CQL mode in the connect() call to the Python driver: *connection = cql.connect('localhost:9160', cql_version='3.0')*

    The documentation there was incorrect also, should be

    con = cql.connect('localhost', cql_version='3.0.0')
    

    Also, Enterprise Opcenter doesn't yet support CQL 3 in DSE.

     cqlsh --cqlversion=3