cassandra input component in Pentaho

Today, I will discuss about “How to use cassandra input component in Pentaho”. For this, the first and foremost criteria is that cassandra database should be downloaded and installed in your local Machine.
Once installation is completed, you can start the Apache-cassandra services using below command.
cassandra.bat -f ( This batch file is present inside bin folder).
In order to create a sample table in the Cassandra database, you need to open another command prompt session where you need to run the cqlsh command(Run this command inside bin folder) which helps to run Cassandra database commmands.

Command to create the keyspace in the cassandra database:
CREATE KEYSPACE IF NOT EXISTS Pentaho WITH REPLICATION = { ‘class’ : ‘NetworkTopologyStrategy’, ‘datacenter1’ : 3 };

Command to create the Table in Pentaho Keyspace:
CREATE TABLE pentaho.emp ( id int PRIMARY KEY, firstname text,lastname text );

Command to insert the records in emp table:
INSERT INTO Pentaho.emp (id,firstname,lastname)
VALUES (1,’Ashok’,’Kukreja’);
INSERT INTO Pentaho.emp (id,firstname,lastname)
VALUES (2,’Ram’,’Sharma’);
INSERT INTO Pentaho.emp (id,firstname,lastname)
VALUES (3,’Sham’,’Mohan’);

Command to get the records from the emp table:
select * from pentaho.emp;
See the below SS for the same.

Now, we will use Cassandra input command to fetch records from this object and generate one text file. See the below snippet of code for the same.


In Cassandra input, you need to set username, password which is your local Machine Credentials, then keyspace which is Pentaho in our case, port number 9042, cassandra host as localhost. See the below SS for the same.


Here, if you can see, we have written CQL Query (CQL : Cassandra Query Language). You can preview the data as well in order to make sure that the values are set correctly or not.




Related posts