How to import PIG data into HBase?

0 votes
Hi. I am new to HBase. I have some data in Pig and now I want to import it in HBase. How can I do it?
Feb 14 in Big Data Hadoop by Praful
116 views

1 answer to this question.

0 votes

Follow the below steps to do it:

# Enter into HBase shell

[training@localhost ~]$ hbase shell

# Create a table ‘customers’ with column family ‘customers_data’

hbase(main):001:0> create 'customers', 'customers_data'

# List the tables


hbase(main):002:0> list

# Exit from HBase shell


hbase(main):003:0> exit

Step 2: Write the following PIG script to load data into the ‘customers’ table in HBase


-- Name your script Load_HBase_Customers.pig

-- Load dataset 'customers' from HDFS location


raw_data = LOAD 'hdfs:/user/training/customers' USING PigStorage(',') AS (

           custno:chararray,

           firstname:chararray,

           lastname:chararray,

           age:int,

           profession:chararray

);


-- To dump the data from PIG Storage to stdout

/* dump raw_data; */


-- Use HBase storage handler to map data from PIG to HBase

--NOTE: In this case, custno (first unique column) will be considered as row key.


STORE raw_data INTO 'hbase://customers' USING org.apache.pig.backend.hadoop.hbase.HBaseStorage(

'customers_data:firstname

 customers_data:lastname

 customers_data:age

 customers_data:profession'

);
answered Feb 14 by Omkar
• 67,290 points

Related Questions In Big Data Hadoop

0 votes
1 answer

How to import data to HBase from SQL server?

You can easily import the data from ...READ MORE

answered Apr 20, 2018 in Big Data Hadoop by kurt_cobain
• 9,240 points
309 views
0 votes
1 answer

How to load data from HDFS into pig relation?

Hey, To load data from HDFS to pig ...READ MORE

answered May 7 in Big Data Hadoop by Gitika
• 25,300 points
31 views
0 votes
1 answer

How to import data to hbase database?

There are 3 Ways to Load Data ...READ MORE

answered Jul 10 in Big Data Hadoop by Karan Reddy
24 views
0 votes
1 answer

How to import data to hbase database?

First you have to have the file ...READ MORE

answered Jul 23 in Big Data Hadoop by Kiran
12 views
0 votes
1 answer
0 votes
1 answer

What do we exactly mean by “Hadoop” – the definition of Hadoop?

The official definition of Apache Hadoop given ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by Shubham
171 views
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,490 points
2,346 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,490 points
238 views
0 votes
1 answer

Hadoop Hive Hbase: How to insert data into Hbase using Hive (JSON file)?

You can use the get_json_object function to parse the ...READ MORE

answered Nov 15, 2018 in Big Data Hadoop by Omkar
• 67,290 points
474 views
0 votes
1 answer

How to convert Spark data into CSV?

You can use this: df.write .option("header", "true") ...READ MORE

answered Nov 21, 2018 in Big Data Hadoop by Omkar
• 67,290 points
45 views