Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Hive, mail # user - Loading json files into hive table is giving NULL as output(data is in s3 bucket)


Copy link to this message
-
Loading json files into hive table is giving NULL as output(data is in s3 bucket)
Chunky Gupta 2013-02-18, 12:43
Hi,

I have data in s3 bucket, which is in json format and is a zip file. I have
added this jar file in hive console :-
http://code.google.com/p/hive-json-serde/downloads/detail?name=hive-json-serde-0.2.jar&can=2&q
I tried the following steps to create table and load data :-

1. CREATE EXTERNAL TABLE table_test ( uname STRING ) PARTITIONED BY (dt
STRING ) ROW FORMAT SERDE "org.apache.hadoop.hive.contrib.serde2.JsonSerde"
WITH SERDEPROPERTIES ( "uname"="$._u" ) LOCATION
's3://BUCKET_NAME/test_data/'

           I tried this also :-

CREATE EXTERNAL TABLE table_test ( uname STRING ) PARTITIONED BY (dt STRING
) ROW FORMAT SERDE "org.apache.hadoop.hive.contrib.serde2.JsonSerde" WITH
SERDEPROPERTIES ( "uname"="_u" ) LOCATION 's3://BUCKET_NAME/test_data/'

2. alter table table_test add partition (dt='13Feb2012') location
's3n://BUCKET_NAME/test_data/13Feb2012';

and json file is like this :-
-------------------------------------
{"_u":"test_name1","_ts":"2012-01-13","_ip":"IP1"}
{"_u":"test_name2","_ts":"2012-01-13","_ip":"IP2"}
{"_u":"test_name3","_ts":"2012-01-13","_ip":"IP3"}
When I query :-
select uname from table_test;

Output :-
NULL 13Feb2012
NULL 13Feb2012
NULL 13Feb2012
Please help me and let me know how to add json data in a table.

Thanks,
Chunky.
+
Dean Wampler 2013-02-18, 12:53
+
Chunky Gupta 2013-02-18, 15:17
+
Chunky Gupta 2013-02-18, 15:31
+
Dean Wampler 2013-02-18, 17:01