Cassandra - SyntaxException: line ... no viable alternative at input in select statement

Viewed 1684

I am trying to select data from cassandra db using below query but it is failing-

SELECT id from keyspace.table where code=123 and toTimestamp(now()) >= some_date;

Error- SyntaxException: line 1:103 no viable alternative at input '(' (...table where code=123 and [toTimestamp](...)

Looks like toTimestamp(now()) is causing the issue. Can someone plz suggest what is the issue and solution to this? Thanks.

1 Answers

You can't use functions in the WHERE statement. So the only workaround is to get current time inside your application, and pass it to the query. This request is tracked as CASSANDRA-8488.

But in reality, your query should have condition on some column, not on the calculated value.

Related