Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Latest commit

 

History

History
21 lines (15 loc) · 725 Bytes

README.md

File metadata and controls

21 lines (15 loc) · 725 Bytes

Cassandra CSV

Simple utility java class to import data from a csv file directly to Cassandra using Spark SQL

Usage

ImportCsv.start(csc)
        // csv path
        .read("cassandra-csv/src/main/resources/example.csv")

        // csv structure
        .schema(schema)

        // options from spark-csv package. see https://github.com/databricks/spark-csv
        .option("header", "true")

        // select expression to be applied on csv data frame
        .selectExpr("id", "type AS transaction_type", "value")

        // keyspace and table name
        .saveToCassandra("my_keyspace", "my_table");

Based on package https://github.com/databricks/spark-csv.