Giter Site home page Giter Site logo

cash's Introduction

Credits

  1. This project is derived from the work done at Riptano (now Datastax)

  2. There wouldn't have been anything if not for the original work done by Edward Capriolo. Look at the Apache Jira here

  3. Majority of the cleanup and upgrade to 1.2.x work was done by the wonderful guys (and our development partners) at Imaginea by Venkatesh Ragi

  4. Thanks to all the other contributors -

And of course countless others how have contributed to Cassandra, Hadoop and Hive and the Open Source community in general. THansk to each and everyone of you!

hive-cassandra-handler

This handler provides hive support for cassandra.

Check out and Installation

check out the project from https://github.com/tuplejump/cash.git.

> git clone https://github.com/tuplejump/cash.git

Go to branch cas-support-cql

> git checkout cas-support-cql

Go to cassandra-handler folder run the maven package command.

> mvn package

This generates a hive-cassandra-x.x.x.jar file in target folder and all other project dependencies are downloaded to target/dependency.

Copy the target/hive-cassandra-x.x.x.jar to the hive lib directory

Copy target/dependency/cassandra-all-x.x.x.jar and target/dependency/cassandra-thrift-x.x.x.jar to hive lib directory.

Running

Start hive

> bin/hive

Create a database in hive (or use an existing one)

To create a cql3 table in cassandra from hive, execute the following command

 hive> CREATE EXTERNAL TABLE test.messages(message_id string, author string, body string)
    STORED BY 'org.apache.hadoop.hive.cassandra.cql.CqlStorageHandler'
    WITH SERDEPROPERTIES ("cql.primarykey" = "message_id, author", "comment"="check", "read_repair_chance" = "0.2",
    "dclocal_read_repair_chance" = "0.14", "gc_grace_seconds" = "989898", "bloom_filter_fp_chance" = "0.2",
    "compaction" = "{'class' : 'LeveledCompactionStrategy'}", "replicate_on_write" = "false", "caching" = "all")

where 'test' is the keyspace in cassandra. The above query also creates a column family in cassandra if does not exist.

Note: By default hive tries to use cassandra running on localhost at port 9160. To change these specify cassandra.host and cassandra.port in the SerDeProperties while creating a table. Hive connects to the specified cassandra instance for further queries to the table.

To create a keyspace that does not exist in cassandra execute the following query

hive> CREATE EXTERNAL TABLE test.messages(row_key string, col1 string, col2 string)
STORED BY 'org.apache.hadoop.hive.cassandra.cql.CqlStorageHandler' WITH SERDEPROPERTIES("cql.primarykey" = "row_key")
TBLPROPERTIES ("cassandra.ks.name" = "mycqlks", "cassandra.ks.stratOptions"="'DC':1, 'DC2':1",
"cassandra.ks.strategy"="NetworkTopologyStrategy");

Note: For brevity, only minimal SERDEPROPERTIES are given in the above query.

If 'test' keyspace does not exist in cassandra it will be created.

Inserting values into CQL3 table through hive:

hive> insert into table messages select * from tweets;

The values from tweets table are appended to messages table.

Note: With Cassandra INSERT OVERWRITE is same as INSERT INTO as Cassandra merges changes if keys are same.

Retrieving values from a CQL3 table using hive:

hive> select * from messages;

Note: If local mode execution is not enabled, hive compiler generates map-reduce jobs for most queries. These jobs are then submitted to the Map-Reduce cluster. The map-reduce jobs need hive-cassandra-handler, cassandra-all and cassandra-thrift jars. Point the HIVE_AUX_JARS_PATH environment variable to the location containing these jars to run those jobs successfully.

While CqlStorageHandler is used to create/access cql3 tables in cassandra, CassandraStorageHandler can be used to create/access thrift tables in cassandra.

cash's People

Contributors

alexoss68 avatar ashutoshc avatar beobal avatar boneill42 avatar bpmason1 avatar cscetbon avatar cwsteinbach avatar jancona avatar omalley avatar richardalow avatar tjake avatar tomwhite avatar venkateshragi avatar zshao avatar

Stargazers

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

Watchers

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

cash's Issues

Cannot connect to Cassandra server with username/password

Hi,

It seems there's no way to specify a username/password when trying to connect to a Cassandra server using the PasswordAuthenticator. When trying to create my EXTERNAL TABLE, i.e.

CREATE EXTERNAL TABLE example (
example_data bigint
)
STORED BY 'org.apache.hadoop.hive.cassandra.cql.CqlStorageHandler'
WITH SERDEPROPERTIES ("cassandra.host" = "1.2.3.4")
TBLPROPERTIES ("cassandra.ks.name" = "test", "cassandra.cf.name" = "example");

`
I get this error message:

FAILED: Error in metadata: MetaException(message:Unable to connect to the server InvalidRequestException(why:You have not logged in))
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

My external table works if I change the server back to AllowAllAuthenticator, but unfortunately that's not really an option.

Would it be possible to add username and password to SERDEPROPERTIES? Or is there a different workaround that I'm missing?

Questions on performance

Hi,

We download the code and were able to make it work both on a localhost deployment of cassandra and a remote deployment. Thanks a lot of the great piece of work that you have shared, and it has saved us a lot of time and effort.

Please find my questions below on performance.

  1. About 275 map jobs are started in hadoop when a simple select count(*) is issued on the hive. This slows down the query enormously if the query is issued on hive on a external table which is located on cassandra. ( about 30 minutes for 150 records)
  2. If I create hive table from external cassandra table it is very slow. ( About 30 minutes.

Is there a work around or something to be expected from hive side.

thanks

Sagar

Exception in thread "main" java.lang.NoSuchMethodError

I realize this is probably not an issue that is directly related to this repo, but I'm really at a loss and am hoping someone is willing to help me anyway.

I followed the steps stated within the README.md, copied the target/hive-cassandra-1.2.9.jar, target/dependency/cassandra-all-1.2.9.jar and target/dependency/cassandra-thrift-1.2.9.jar to the hive lib directory, added hive/lib to HIVE_AUX_JARS_PATH and also added HIVE_CLASSPATH=$HIVE_HOME/lib/*.jar to the hadoop user's .bashrc

After that I was able to create an external table with command:
CREATE EXTERNAL TABLE service.feeds(asset_id int, created_date string, created_timestamp string, type_id int, value string) STORED BY 'org.apache.hadoop.hive.cassandra.cql.CqlStorageHandler' WITH SERDEPROPERTIES ("cassandra.host"="external.cassandra.host", "cassandra.port"="9160", "cql.primarykey"="asset_id, created_date", "caching"="all") TBLPROPERTIES ("cassandra.ks.name"="service", "cassandra.cf.name"="feeds", "cassandra.ks.strategy"="SimpleStrategy");

resulting in:
OK
Time taken: 0.758 seconds

When I query that table, I get an exception within the main thread upon which hive crashes:

hive>select * from service.feeds limit 10;
OK
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.hive.serde2.ColumnProjectionUtils.getReadColumnIDs(Lorg/apache/hadoop/conf/Configuration;)Ljava/util/ArrayList;
at org.apache.hadoop.hive.cassandra.input.cql.HiveCqlInputFormat.getRecordReader(HiveCqlInputFormat.java:73)
at org.apache.hadoop.hive.ql.exec.FetchOperator.getRecordReader(FetchOperator.java:471)
at org.apache.hadoop.hive.ql.exec.FetchOperator.getNextRow(FetchOperator.java:561)
at org.apache.hadoop.hive.ql.exec.FetchOperator.pushRow(FetchOperator.java:534)
at org.apache.hadoop.hive.ql.exec.FetchTask.fetch(FetchTask.java:137)
at org.apache.hadoop.hive.ql.Driver.getResults(Driver.java:1519)
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:285)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:220)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:423)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:792)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:686)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:625)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.main(RunJar.java:160)

I am not really sure where it is going wrong, so could someone please help me out?

Cassandra version: 2.0.9
Hive version: 0.13.1
Hadoop version: 1.2.1

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.