Question

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.

Était-ce utile?

La solution

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.

Autres conseils

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

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top