Alternative for OR condition after where clause in select statement Cassandra

cassandracqlselectwhere

Is it possible in Cassandra to use multiple conditions union ed together after the where clause in a select statement like in any of the RDBMS. Here is my code :

SELECT * from TABLE_NAME WHERE COND1= 'something' OR COND2 = 'something';  

Best Answer

Assuming COND is the name of your table's primary key, you can do:

SELECT * from TABLE_NAME WHERE COND1 in ('something', 'something');

So, there is no fully general OR operation, but it looks like this may be equivalent to what you were trying to do.

Remember, as you use CQL, that query planning is not meant to be one of its strengths. Cassandra code typically makes the assumption that you have huge amounts of data, so it will try to avoid doing any queries that might end up being expensive. In the RMDBS world, you structure your data according to intrinsic relationships (3rd normal form, etc), whereas in Cassandra, you structure your data according to the queries you expect to need. Denormalization is (forgive the pun) the norm.

Point is, CQL is intended to be a more familiar, friendly syntax for making Cassandra queries than the older Thrift RPC interface. It's not intended to be completely expressive and flexible the way that SQL is.