We're looking to be able to do something like..
select * from User where rewards.size > 0
when the schema is
create table user (
id uuid primary key,
network_id uuid,
rewards set<uuid>,
name text
);
CQL does not support wildcard queries. CQL does not support Union, Intersection queries. Table columns cannot be filtered without creating the index. Greater than (>) and less than (<) query is only supported on clustering column.
cqlsh is a command-line interface for interacting with Cassandra using CQL (the Cassandra Query Language). It is shipped with every Cassandra package, and can be found in the bin/ directory alongside the cassandra executable.
sadly Cassandra is eager performing very quick reads and on the other hand is not perfectly done supporting collections: Get count of elements in Set type column in Cassandra
unfortunately the Collections-support even in CQL Driver v2 is not perfect: you may add or delete items in upsert statements. But more on them, like doing an item select, asking for collection item's TTLs or asking for the collection's size, is not supported. So you have to
resultset: SELECT collection_column FROM ...
and then take item byresultset.one()
orresultset.all()
and getitem.size()
yourself.
What you want to do is adding an indexed column with a counter to count and fast-read the element count. Iff you just want to know whether the collection is not empty you may need an index column with a boolean. The index makes sure you can scan the columns efficiently.
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