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
62 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 65,850 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,260 points
245 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
• 8,140 points
10 views
+1 vote
1 answer

How to print data without brackets using PIG Dump?

Please refer to the below commands: student = ...READ MORE

answered Dec 18, 2018 in Big Data Hadoop by Omkar
• 65,850 points
47 views
0 votes
1 answer

How to import data in sqoop as a Parquet file?

Sqoop allows you to import the file ...READ MORE

answered May 15 in Big Data Hadoop by Nanda
13 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
119 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
• 9,030 points
1,666 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
• 9,030 points
130 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
• 65,850 points
236 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
• 65,850 points
33 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.