PLANNED MAINTENANCE

Hello, DataStax Community!

We want to make you aware of a few operational updates which will be carried out on the site. We are working hard to streamline the login process to integrate with other DataStax resources. As such, you will soon be prompted to update your password. Please note that your username will remain the same.

As we work to improve your user experience, please be aware that login to the DataStax Community will be unavailable for a few hours on:

  • Wednesday, July 15 16:00 PDT | 19:00 EDT | 20:00 BRT
  • Thursday, July 16 00:00 BST | 01:00 CEST | 04:30 IST | 07:00 CST | 09:00 AEST

For more info, check out the FAQ page. Thank you for being a valued member of our community.


question

ssnmurtyraju_188715 avatar image
ssnmurtyraju_188715 asked ·

TOKEN() query returning "no viable alternative at input 'TOKEN()'"

Hi

I am trying to run below query against Cassandra table using datastax python cassandra connector. I am getting "no viable alternative at input 'TOKEN (...ECT TOKEN...)" error. Is there anything wrong in the query? Please help me as i am new to Cassandra.

statement = SimpleStatement("SELECT TOKEN(doc_id), doc_id FROM <ks>.<tablename> WHERE TOKEN(doc_id)>-8939575974182321168 AND TOKEN(doc_id)<8655779911509866528", fetch_size=30)
rows = session.execute(statement)


cassandra
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

@ssnmurtyraju_188715 It appears you're hitting a CQL syntax error and this isn't a problem with the Python driver. The query you posted looks OK so I'm assuming you didn't paste the exact query you have in your code.

If you run the exact same query in cqlsh that you have in your code, you'll be able to work which part of your query is faulty. Cheers!

UPDATE - From question #3667, you indicated that you're connecting to Azure's Cosmos DB. It's not working because even though Cosmos DB provides a CQL-like API, it's not running Apache Cassandra under the hood so you'll find that there are several unsupported Cassandra features/functionality in Cosmos DB.

My suggestion is to use DataStax Astra instead which is built on Apache Cassandra. It's FREE to try without a credit card and you can launch a database instance in just a few clicks. Cheers!

1 comment Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thanks for reply. It worked after removing TOKEN(doc_id) from columns section but WHERE condition remains same. SELECT doc_id FROM <ks>.<tablename> WHERE TOKEN(doc_id)>-8939575974182321168 AND TOKEN(doc_id)<8655779911509866528"

0 Likes 0 · ·