我有一個像這樣的json對象數組。 [ { "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" } ]
我需要在配置單元中使用此數組的json對象創建外部表,爲此我嘗試這個查詢哪些不起作用請幫助我這個查詢。如何使用json對象數組創建外部配置單元表
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' ;
爲這種JSON對象陣列的所需的任何特定SERDE。
是否有錯誤,你可以分享? – shainnif 2014-11-05 10:54:06
表正在創建,但一旦你在hcataloge中打開它會發出以下錯誤:java.io.IOException:org.apache.hadoop.hive.serde2.SerDeException:行不是有效的JSON對象 - JSONException:缺少值1 [字符2行1]'因此表正在創建,但沒用。 – 2014-11-05 11:20:50