Git Product home page Git Product logo

cassandra-spark-jdbc-bridge's Introduction

cassandra-spark-jdbc-bridge

If you want to query Cassandra data via JDBC but you want to use the power of Spark SQL for data processing, you need this application.

This app (CSJB), which is a Spark app, will automatically registers all Cassandra tables as schema RDDs in Spark SQL and starts an embedded Apache HiveThriftServer to make the RDDs ready to be consumed via "jdbc:hive2" protocol.

With this bridge/server, you can use any BI tool like Jasper, Pentaho or Tableau to query Cassandra tables via Spark SQL. You will be able to do many different aggregation and/or filtering operations like group by, join, etc.. with Cassandra data.

This application uses the Datastax's spark-cassandra-connector

Notes:

  • Cassandra tables are registered in Spark SQL using naming format below: keyspace_tableName Example: "mykeyspace.test" table in Cassandra will be registered as "mykeyspace_mytable" schema RDD.

  • As of now, CSJB only supports Cassandra tables with the following data types: AsciiType, BooleanType, BytesType,CounterColumnType, DateType, DecimalType, DoubleType, LongType, FloatType, Int32Type, IntegerType, LexicalUUIDType, UTF8Type, UUIDType, TimestampType, ReversedType (for TimestampType). More data types will be added in the near future (your contributions will be greatly appreciated).

============= Getting started

Prerequisites

  • Install and start Cassandra 2.1
  • Install and start Spark 1.2

Build

sbt assembly copyAssets

A fat assembly jar and config files will be generated in "target/dist"

Set environment variables

export INADCO_CSJB_HOME=`pwd`/target/dist
export SPARK_HOME=YOUR_SPARK_HOME_DIR

Enter Cassandra credentials and Spark master url

Default config values are in $INADCO_CSJB_HOME/dist/config/csjb-default.properties

spark.cassandra.connection.host=localhost
spark.cassandra.auth.username=CASSSANDRA_USER_NAME
spark.cassandra.auth.password=CASSSANDRA_PASSWORD
inadco.spark.master=local[2]

Start CSJB server

$INADCO_CSJB_HOME/bin/start.sh

The CSJB server is started at port 10000 (to stop it, run $INADCO_CSJB_HOME/bin/stop.sh) Status of CSJCB app is available via your Spark UI http://YOUR_SPARK_MASTER:8080/

Query your data

Run a client which supports "jdbc:hive2" protocol (e.g "beeline") and connect your CSJB server to query existing data in Cassandra (if you don't have the data yet, run cql and create a test table and insert some data in Cassandra first)

$SPARK_HOME/bin/beeline
beeline> !connect jdbc:hive2://localhost:10000
0: jdbc:hive2://localhost:10000> select id, sum(count) from mykeyspace_mytable group by id;

cassandra-spark-jdbc-bridge's People

Contributors

hduong avatar hungduong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cassandra-spark-jdbc-bridge's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.