Keerthana A
Keerthana A

Reputation: 57

creating hive table from non nested json data file gives output as null

I am trying to create a Hive table("desiredtable") from a json file present in hdfs.
Below are the steps I have followed :

Initially i have copied the hive-serdes-1.0-SNAPSHOT.jar into the hive/lib folder.

1.  add jar /usr/local/hive/lib/hive-serdes-1.0-SNAPSHOT.jar;
2.  create external table sample_data (reviewerID string , reviewText string )
    row format serde 'com.cloudera.hive.serde.JsonSerDe'
    location '/dataset';
3.  create table desiredtable as select * from sample_data;
4.  select * from desiredtable ;

But on executing the 4th step, it returns null values as shown in the [image][1] below.
Json data is of the form below :

{
    "reviewerID": "A00000262KYZUE4J55XGL",
    "asin": "B003UYU16G",
    "reviewerName": "Steven N Elich",
    "helpful": [0, 0],
    "reviewText": "It is and does exactly what the description said it would be and would do. Couldn't be happier with it.",
    "overall": 5.0,
    "summary": "Does what it's supposed to do",
    "unixReviewTime": 1353456000,
    "reviewTime": "11 21, 2012"
}

{
    "reviewerID": "A000008615DZQRRI946FO",
    "asin": "B005FYPK9C",
    "reviewerName": "mj waldon",
    "helpful": [0, 0],
    "reviewText": "I was sketchy at first about these but once you wear them for a couple hours they break in they fit good on my board an have little wear from skating in them. They are a little heavy but won't get eaten up as bad by your grip tape like poser dc shoes.",
    "overall": 5.0,
    "summary": "great buy",
    "unixReviewTime": 1357603200,
    "reviewTime": "01 8, 2013"
}

Kindly guide on what is the mistake that i have committed ?

Upvotes: 2

Views: 305

Answers (1)

Indent
Indent

Reputation: 4967

It's a case sensitive problem. SQL columns are case insensitive but JSON key not.

You need use lower case in JSON key.

Old Hive version don't support mixed case in JSON Key.

https://github.com/rcongiu/Hive-JSON-Serde/issues/4

Upvotes: 1

Related Questions