Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Cassandra Handler usage in Hive 0.7 with Cassandra 0.7

julieZhang edited this page May 23, 2011 · 3 revisions

You can use Cassandra Handler in Hive 0.7 against Cassandra 0.7 cluster. To use it, please following the instructions as below:

apache-cassandra-0.7.6.jar (or the apache cassandra of the version that you are using.)
guava-r05    .jar
commons-lang-2.4.jar

  • Define a property in your hive-site.xml and add your jars from there. For more details, please refer to this link:
    [[http://mail-archives.apache.org/mod_mbox/hive-user/201011.mbox/%3CAANLkTimLwT++92gLu9-puekXh9_g7aX=[email protected]%3E|http://mail-archives.apache.org/mod_mbox/hive-user/201011.mbox/%3CAANLkTimLwT++92gLu9-puekXh9_g7aX=[email protected]%3E]]
    <property> <name>hive.aux.jars.path</name> <value>file:///path/to/guava-r05.jar,file:///path/to/commons-lang-2.4.jar,file:///path/to/apache-cassandra-0.7.6.jar,file:///path/to/hive-cassandra-handler-0.7.0-beta1.jar</value> </property>

  • Now you can use the CREATE EXTERNAL TABLE ... STROED BY '' to create the external table in Hive and start accessing it.

    hive> CREATE TABLE invites (foo INT, bar STRING);
    hive> LOAD DATA LOCAL INPATH '/root/kv1.txt' OVERWRITE INTO TABLE invites;
    hive> CREATE EXTERNAL TABLE invites2 (foo INT, bar STRING)
    STORED BY 'org.apache.hadoop.hive.cassandra.CassandraStorageHandler'
    WITH SERDEPROPERTIES (
    "cassandra.host" = "127.0.0.1",
    "cassandra.port" = "9160",
    "cassandra.ks.name" = "examples",
    "cassandra.cf.name" = "invites2" );
    hive> select count(*) from invites2;
    hive> INSERT OVERWRITE TABLE invites2 select foo, bar from invites;
    hive> select foo, bar from invite2s;

Please refer to the http://www.datastax.com/docs/0.8/brisk/about_hive page for more information.

Clone this wiki locally