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
8,552 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,090 points
1,595 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
317 views
0 votes
1 answer

Writing File into HDFS using spark scala

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

answered Apr 5, 2018 in Big Data Hadoop by kurt_cobain
• 9,390 points
12,294 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
1,564 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
6,852 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
1,098 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
48,385 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,390 points
2,600 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
661 views