CacheCort
CacheCort

Reputation: 33

How to insert on-fly query data to HBase using Hive

I am new in Hbase and Hive. Can someone please explain me how to insert data into Hbase using Hive?

I found a lot of information regarding to this, but all of them are talking about exactly the same thing. In other words, they are inserting into Hbase table from another already existing table.

In my case it is different. I have an application which reads some data from users and sends to the server and incoming data needs to be written in Hbase table. How can I do that?

Here is my table:

CREATE TABLE hive_table (key INT, username STRING, password STRING, address STRING) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
WITH SERDEPROPERTIES('hbase.columns.mapping'=':key, user:val')
TBLPROPERTIES('hbase.table.name'='hbase_table');

How can I insert following record to my Hbase table which is hbase_table using Hive:

key=123, username='something', password='pass', address='somewhere';

Upvotes: 0

Views: 1970

Answers (1)

anon
anon

Reputation:

Hive does not provide any support for the ANSI SQL INSERT INTO table VALUES (a, b, c, d) insert statement. If you have another table or file that contains the data in question, you can make the insert using something like

INSERT INTO hive_table SELECT key, username, password, address FROM foo

If you want to interact with HBase directly, I suggest using:

  1. HBase shell
  2. Phoenix
  3. Kiji

Upvotes: 1

Related Questions