Spark program to load a table data from Cassandra to Hive using Java

Hey there!

Welcome to ClearUrDoubt.com.

In this post, we will look at a Spark program to load a table data from Cassandra to Hive using Java.

Step 1: Create a table in Cassandra and insert records into it.

 

Step 2: Write a Spark program to connect to Cassandra using Java.

pom.xml

 

spark-submit command:

Output:

 

Step 3: Let’s create a HIVE table on the output location(i.e., hdfs://localhost:9000/hdfs_home/clearurdoubt/datafiles/clearurdoubt/data/students) and check the imported data.

The 5 records have been imported from Cassandra successfully.

Happy learning :).

Please leave a reply in case of any queries.

Leave a Reply

Your email address will not be published. Required fields are marked *