Stored Procedure with Cassandra

1,687 views
Skip to first unread message

imene....@gmail.com

unread,
Aug 1, 2014, 5:40:02 AM8/1/14
to java-dri...@lists.datastax.com
Hello 

My internship consist in developing a component using vertx and Cassandra technologies .
So i have some stored procedure written in SQL (DROP PROCEDURE IF EXISTS ``// CREATE PROCEDURE `` ...)  that i have to write them with Cassandra .
But the problem is that i don't find any support about writing SP with nosql language and precisely with Cassandra .
Can anyone help me ?!!

Thxs .

Rick Bullotta

unread,
Aug 1, 2014, 7:29:18 AM8/1/14
to java-dri...@lists.datastax.com
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.

Olivier Michallat

unread,
Aug 1, 2014, 9:38:26 AM8/1/14
to java-dri...@lists.datastax.com
Hi Imene,

Cassandra doesn't really have the equivalent of stored procedures. Triggers were introduced recently and user-defined functions are coming soon, but I don't think this covers everything you can do with, say, PL/SQL.

If you need to port a legacy app written with stored procedures, the idea is to move that business logic to your application layer, and send requests to Cassandra to load and store data. There are drivers for many languages so you can pick the one you're most comfortable with, here is a good starting point: http://planetcassandra.org/client-drivers-tools. Since you mention Vert.x, this project is probably worth a look: https://github.com/nea/vertx-mod-cassandra-persistor

I suggest you check with the person in charge of your internship that this is the intended approach.

Good luck,
-- Olivier


To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.

Imen Jaouani

unread,
Aug 1, 2014, 10:43:57 AM8/1/14
to java-dri...@lists.datastax.com
Thank u Olivier for ur help for the information ! In fact , that's what i have concluded after my research , that there is not really an equivalent for stored procedures !
I have already exploited vertx-mod-cassandra-persistor project ! it was very useful and i have tested : select / insert/ update and delete throw a rest / web service and made a stress test with jmeeter in order to compare performance between node+ cassandra and vertx+cassandra . and i have obtained a better result with vertx !
So that ,as you have said : i should implement stored procedure that i have writen in SQL to write them as java class and use cassandra only to load and store data ! 


Imen Jaouani

unread,
Aug 1, 2014, 10:44:34 AM8/1/14
to java-dri...@lists.datastax.com
Thank u Olivier for ur help !

Imen Jaouani

unread,
Aug 1, 2014, 10:44:52 AM8/1/14
to java-dri...@lists.datastax.com

Imen Jaouani

unread,
Aug 1, 2014, 10:45:15 AM8/1/14
to java-dri...@lists.datastax.com
Thank u Olivier for ur help  ! In fact , that's what i have concluded after my research , that there is not really an equivalent for stored procedures !
I have already exploited vertx-mod-cassandra-persistor project ! it was very useful and i have tested : select / insert/ update and delete throw a rest / web service and made a stress test with jmeeter in order to compare performance between node+ cassandra and vertx+cassandra . and i have obtained a better result with vertx !
So that ,as you have said : i should implement stored procedure that i have writen in SQL to write them as java class and use cassandra only to load and store data ! 

Imen Jaouani

unread,
Aug 5, 2014, 7:12:32 AM8/5/14
to java-dri...@lists.datastax.com
Hi Cassandra Friends ,

To convert this stored procedure from sql to Cassandra and i find also some difficulties ,like this one :

 SELECT `service_type_id`,
           `quantity`,
           `replay_delta`,
           `status`
      INTO t_service_type,
           t_quantity,
           t_replay_delta,
           t_status
      FROM `service_type`
     WHERE `service_name` = i_service_name;


I have to store the select results in some variables : quantity to t_quantity ...etc

Is there someone who can help me to find the equivalent for this syntax in Cassandra.

Thxs.

Olivier Michallat

unread,
Aug 5, 2014, 9:06:25 AM8/5/14
to java-dri...@lists.datastax.com
Hi Imen,

CQL does not have SELECT...INTO, what you do instead is run your query with the driver and retrieve the columns from the resulting ResultSet.

Here's a tutorial that will show you how this works with the Java driver:


To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.

Imen Jaouani

unread,
Aug 6, 2014, 3:56:03 AM8/6/14
to java-dri...@lists.datastax.com
Thank u Olivier ! yes , i tested that in other project and that work perfectly ! but in my case , i'll need that procedure many time so that i will create a package whose classes will make the mapping between database and object so that i'll explore object which is easier i find :)
Have a nice day :)

Imen Jaouani

unread,
Aug 20, 2014, 5:05:42 AM8/20/14
to java-dri...@lists.datastax.com
Hi all ;

I have to fill a table using jmeeter !
My Cassandra table include timestamp as a date form and with jmeter i use the function ${__time(yyyyMMddHHmmss)} wich return a date with yyyyMMddHHmmss form !
so how can i convert this form with java code to make it adequate to insert in timestamp field in the table ! thank you
Reply all
Reply to author
Forward
0 new messages