How to create external hive table using json array

I have an array of json object like this. [ { "id": 2, "createdBy": 0, "status": 0, "utcTime": "Oct 14, 2014 4:49:47 PM", "placeName": "21/F, Cunningham Main Rd, Sampangi Rama NagarBengaluruKarnatakaIndia", "longitude": 77.5983817, "latitude": 12.9832418, "createdDate": "Sep 16, 2014 2:59:03 PM", "accuracy": 5, "loginType": 1, "mobileNo": "0000005567" }, { "id": 4, "createdBy": 0, "status": 0, "utcTime": "Oct 14, 2014 4:52:48 PM", "placeName": "21/F, Cunningham Main Rd, Sampangi Rama NagarBengaluruKarnatakaIndia", "longitude": 77.5983817, "latitude": 12.9832418, "createdDate": "Oct 8, 2014 5:24:42 PM", "accuracy": 5, "loginType": 1, "mobileNo": "0000005566" }, { "id": 1, "createdBy": 13, "status": 1, "utcTime": "Oct 14, 2014 4:57:43 PM", "placeName": "21/F, Cunningham Main Rd, Sampangi Rama NagarBengaluruKarnatakaIndia", "longitude": 77.5983817, "latitude": 12.9832418, "createdDate": "Sep 15, 2014 12:10:44 PM", "accuracy": 5, "loginType": 1, "mobileNo": "8147708287" }, { "id": 3, "createdBy": 0, "status": 0, "placeName": "no", "longitude": 0, "latitude": 0, "createdDate": "Sep 16, 2014 6:45:50 PM", "accuracy": 2, "loginType": 1, "mobileNo": "9861198611" }, { "id": 6, "createdBy": 0, "status": 0, "utcTime": "Oct 14, 2014 4:49:47 PM", "placeName": "no", "longitude": 0, "latitude": 0, "createdDate": "Oct 8, 2014 6:51:35 PM", "accuracy": 0, "loginType": 1, "mobileNo": "221133447" }, { "id": 5, "createdBy": 0, "status": 0, "utcTime": "Oct 14, 2014 4:49:47 PM", "placeName": "no", "longitude": 0, "latitude": 0, "createdDate": "Oct 8, 2014 6:43:41 PM", "accuracy": 0, "loginType": 1, "mobileNo": "5585869635" } ]

and i need to create an external table in hive using this json object array, for that i am trying this query which is not working please help me with this query.

ADD JAR json-serde-1.1.9.2-Hive13.jar; CREATE EXTERNAL TABLE mobile_structuring_table( id int, createdBy string, status string, utcTime string, placeName string, longitude double, latitude double, createdDate string, accuracy string, loginType string, mobileNo string ) ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe' LOCATION '/user/root/mobile_data/rest_api_mobile_data.json' ;

is any specific serde needed for this kind of arrays of json objects.

+3


source to share


1 answer


Remove square brackets from your json file. He expects them to be in



{...........}
{...........}
{...........}

      

0


source







All Articles