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...)
The main difference from SQL is that Cassandra does not support joins or subqueries.
The LIMIT option sets the maximum number of rows that the query returns: SELECT lastname FROM cycling. cyclist_name LIMIT 50000; Even if the query matches 105,291 rows, Cassandra only returns the first 50,000.
The GROUP BY option can condense all selected rows that share the same values for a set of columns into a single row. Using the GROUP BY option, rows can be grouped at the partition key or clustering column level. Consequently, the GROUP BY option only accepts primary key columns in defined order as arguments.
No joins. You cannot perform joins in Cassandra. If you have designed a data model and find that you need something like a join, you'll have to either do the work on the client side, or create a denormalized second table that represents the join results for you.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With