Tuesday, February 2, 2016

Apache Hive - JSON Data Processing

Apache Hive - Playing With JSON Data

In one of my assignment, I have to process JSON data using Apache Hive. Definitely here I will explain how anybody can play with JSON data using Apache Hive.






















Suppose we are having following Employee Data into JSON format.

Employee Json:


{"Name":"Bill Gates","Email":"BillGates@Microsoft.Com", "Contact":"XXXXXXXXXX"},
{"Name":"Steve Jobs","Email":"SteveJobs@Apple.Com", "Contact":"XXXXXXXXXX"},
{"Name":"Iqubal M Kaki","Email":"IqubalMKaki@IMU.Com", "Contact":"8390900000"}

Steps for loading JSON Data into Hive Table

Step:1 Create a Hive table and load the JSON file into the table

hive> create table CompanyJSONTable(JSONDATA String);

hive> load data local inpath '/home/hadoopadmin/Desktop/EmployeeJson' into table CompanyJSONTable;

Step:2 Process Above Hive Table Data Using get_json_object() Method

From above created table we will fetch the JSON data using get_json_object method.

hive> select get_json_object(JSONDATA,'$.Name') as Name, get_json_object(JSONDATA,'$.Email') as Email ,get_json_object(JSONDATA,'$.Contact') as Contact from CompanyJSONTable;

OK
Bill Gates BillGates@Microsoft.Com XXXXXXXXXX
Steve Jobs SteveJobs@Apple.Com XXXXXXXXXX
Iqubal M Kaki IqubalMKaki@IMU.Com 8390900000

Time taken: 0.943 seconds, Fetched: 3 row(s)

























Hope you have enjoyed the article.
Author : Iqubal Mustafa Kaki, Technical Specialist

Want to connect with me
If you want to connect with me, please connect through my email - 
iqubal.kaki@gmail.com

5 comments:

  1. nice blog for hive json data processing..thankyou..
    and also see our blog for hive json..
    http://bit.ly/2c2cQsO

    ReplyDelete
  2. Thanks for sharing such a wonderful information on Big Data Big Data Hadoop Online Training Hyderabad

    ReplyDelete
  3. Nice post ! Thanks for sharing valuable information with us. Keep sharing..Hadoop Admin Online Training Hyderabad

    ReplyDelete
  4. It's a great post! Thank you for sharing your knowledge to others, it was very informative and in depth one.
    Apache Pig Training in Electronic City

    ReplyDelete
  5. Great read! Every business has unique goals, and custom website development allows companies to create websites that perfectly match their brand and requirements. BuildWebSEO specializes in tailored web development solutions.

    ReplyDelete