'mismatched input ')' expecting EOF in CQL

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.



Solution 1:[1]

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.

Solution 2:[2]

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

Solution 3:[3]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Richard
Solution 2 Shams
Solution 3 Nandhu Saran