3

created keyspace and using CQL but getting an Error

CREATE KEYSPACE demodb
           WITH strategy_class = 'org.apache.cassandra.locator.SimpleStrategy'
  ...          AND strategy_options:replication_factor='1';

cqlsh:demodb> CREATE TABLE users (
      ...                 user_name varchar,
      ...                 password varchar,
      ...                 gender varchar,
      ...                 session_token varchar,
      ...                 state varchar,
      ...                 birth_year bigint,
      ...                 PRIMARY KEY (user_name)
      ...               );
Bad Request: line 1:163 mismatched input ')' expecting EOF

why am i getting this error,any help,thanks.

user2801682
  • 177
  • 2
  • 2
  • 12

3 Answers3

5

Cassandra 1.0 has CQL2, and your statement is only valid in CQL3. You should upgrade to 1.2.10 or 2.0.1 since 1.0 is very old and CQL2 is deprecated.

Richard
  • 11,050
  • 2
  • 46
  • 33
  • Do i have to upgrade dsc as well and to which version ?,thank you so much. – user2801682 Sep 28 '13 at 13:33
  • DSC is the Datastax distribution of Cassandra - you either want this or the Apache release. – Richard Sep 28 '13 at 13:37
  • i want DSC only as i am on ubuntu so to run CQL ??i have installed cassandra without DSC then i was unable to use cqlsh in that then i moved to dsc,any help in this direction,thanks. – user2801682 Sep 28 '13 at 13:42
0

I was getting same error. But in my case the issue was, as I was using Cassandra reserved Keywords as my column name. In your case as well, password is a reserved keyword.

Check all Cassandra's reserved keywords at: https://docs.datastax.com/en/cql-oss/3.3/cql/cql_reference/keywords_r.html

Shams
  • 3,637
  • 5
  • 31
  • 49
-1

At times, errors come because the syntax may be wrong. Check if the brackets are properly closed. Try storing the query as a string and print it. If it is right, then as Richard said, you may have a problem with the version of CQL. Else it is just a syntax error, which you have to closely look.