Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested query not working in Cassandra

USE users_tracking;
SELECT user_name FROM visits
where port_name IN 
(SELECT port_name FROM ports where location = 'NY' )//as temp;

It gives an error mismatched input 'SELECT' expecting RULE_T_R_PAREN

Is there any way I can store the inner query in a variable and then use that? I tried using set@varname := query but it does not recognize the set command.

like image 626
pizzaEatingGuy Avatar asked Dec 13 '14 14:12

pizzaEatingGuy


People also ask

Does Cassandra support nested queries?

Cassandra cannot do joins or subqueries. Rather, Casssandra emphasizes denormalization through features like collections. A column family (called "table" since CQL 3) resembles a table in a RDBMS (Relational Database Management system).

How do you write a nested query in Cassandra?

Nested queries are not allowed in Cassandra CQL. For this kind of complex querying feature you'll need to use Hive or SparkSQL.

What is allow filtering in Cassandra?

Cassandra will request ALLOW FILTERING as it will have to first find and load the rows containing Jonathan as author, and then to filter out the ones which do not have a time2 column equal to the specified value. Adding an index on time2 might improve the query performance.

Can we use in clause in Cassandra?

Using the SELECT command with the IN keyword. The IN keyword can define a set of clustering columns to fetch together, supporting a "multi-get" of CQL rows. A single clustering column can be defined if all preceding columns are defined for either equality or group inclusion.


1 Answers

Nested queries are not allowed in Cassandra CQL. For this kind of complex querying feature you'll need to use Hive or SparkSQL.

Here is a full CQL reference, http://cassandra.apache.org/doc/cql3/CQL.html

like image 78
RussS Avatar answered Sep 18 '22 18:09

RussS