Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prepared Statement with collection in IN clause in Datastax Cassandra CQL driver

I am trying to run the following query

SELECT edge_id, b_id FROM booking_by_edge WHERE edge_id IN ?

I bind Java list of Long's as a parameter and I get an exception

SyntaxError: line 0:-1 mismatched input '<EOF>' expecting ')' (ResultSetFuture.java:242)

If I try to use (?) it expects single Long item to be bound, but I need a collection

Is there an error in my syntax?

like image 726
i.petruk Avatar asked Jun 04 '13 13:06

i.petruk


1 Answers

Tested in Cassandra 2.1.3, the following code snippet works:

PreparedStatement prepared = session.prepare("SELECT edge_id, b_id FROM booking_by_edge WHERE edge_id IN ?;");
List<Long> edgeIds = Arrays.asList(1L, 2L, 3L);
session.execute(prepared.bind(edgeIds));
like image 136
gcvt Avatar answered Sep 22 '22 10:09

gcvt