Import JSON file into hive

0 votes
I'm working on an exercise to load JSON file into hive.

I know only to load text file but no idea about json. Could you please tell me example with explanation with steps to load implement this requirement.?
Jul 15, 2019 in Big Data Hadoop by Kiran
14,681 views

1 answer to this question.

0 votes

There are two ways to load json file formats into hive.

1.

create table json_guru(str string);
load data inpath 'home/hduser/test.json' into table json_guru;
select * from json1;
select get_json_object(str,'$.ecode') as ecode, get_json_object(str,'$.ename') as ename ,get_json_object(str,'$.sal') as salary from json_guru;

where the json data somewhat looks like this.

image

2.

The second way is to use hive json serde jar to do the same . Please have a look below for your reference.

CREATE TABLE my_table (field1 string, field2 int,

field3 string, field4 double)

ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde' ;

Add the Jar :- ADD JAR /path-to/hive-json-serde.jar;

load the file :- load data inpath 'folder/to/json/data.json' into my_table;
answered Jul 15, 2019 by Guru

Related Questions In Big Data Hadoop

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,220 points
2,946 views
0 votes
1 answer

How to import tables into Hive from Sqoop?

Very simple, in your sqoop command that ...READ MORE

answered May 15, 2019 in Big Data Hadoop by John
1,080 views
0 votes
1 answer

Writing File into HDFS using spark scala

The reason you are not able to ...READ MORE

answered Apr 6, 2018 in Big Data Hadoop by kurt_cobain
• 9,350 points
17,375 views
0 votes
1 answer

What are the various ways to import files into HDFS?

There are various tools and frameworks available ...READ MORE

answered Apr 13, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
3,607 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
11,072 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,571 views
+2 votes
11 answers

hadoop fs -put command?

Hi, You can create one directory in HDFS ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
109,058 views
–1 vote
1 answer

Hadoop dfs -ls command?

In your case there is no difference ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by kurt_cobain
• 9,350 points
4,639 views
0 votes
1 answer

Hive with JSON: getting EOF exception while querying

You are missing the commas in your ...READ MORE

answered Aug 30, 2018 in Big Data Hadoop by Neha
• 6,300 points
1,763 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