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 in Big Data Hadoop by Kiran
824 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 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
• 68,480 points
714 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 in Big Data Hadoop by John
88 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,280 points
6,569 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
• 10,800 points
429 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
• 10,800 points
3,565 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
• 10,800 points
447 views
+1 vote
11 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
18,335 views
0 votes
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,280 points
1,326 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,280 points
227 views