Reputation: 1016
I'm trying to recover the last state of my object, but this sub select does not work, I've seen that the new version of cassandra db supports aggregate operations and subqueries.
select * from event_store
where event_version = (select max(event_version) from event_store)
ALLOW FILTERING;
SyntaxException: line 1:49 no viable alternative at input 'select' (...from event_store where event_version = [(]select...)
Upvotes: 8
Views: 12322
Reputation: 2101
You can do this by using 2 separate queries:
select max(event_version) from event_store;
and then
select * from event_store where event_version = 2 allow filtering;
I might be a bit outdated but it looks like there is no sub select support:
Work on this ticket is stopped
https://issues.apache.org/jira/browse/CASSANDRA-8846
There were some attempts to do this:
https://github.com/jobmthomas/Cassandra-SubQuery
But overall this is just not supported in cassandra.
Upvotes: 13