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 15, 2019 in Big Data Hadoop by Praful
1,495 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 15, 2019 by Omkar
• 69,210 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,390 points
1,393 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, 2019 in Big Data Hadoop by Gitika
• 65,910 points
2,871 views
0 votes
1 answer

How to import data to hbase database?

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

answered Jul 10, 2019 in Big Data Hadoop by Karan Reddy
5,018 views
0 votes
1 answer

How to import data to hbase database?

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

answered Jul 23, 2019 in Big Data Hadoop by Kiran
2,402 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
1,623 views
+1 vote
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
• 11,380 points
10,604 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
• 11,380 points
2,208 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
• 69,210 points
2,641 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
• 69,210 points
3,991 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP