我試圖在Hive中創建一個外部表,以便將Json數據作爲Web Service的響應來獲取。錯誤在Hive中創建外部表以保存JSON數據
JSON文件數據低於此基礎上,我創建外部表模式下式給出:
{
"location": {
"name": "Paris",
"region": "Ile-de-France",
"country": "France",
"lat": 48.87,
"lon": 2.33,
"tz_id": "Europe/Paris",
"localtime_epoch": 1486792043,
"localtime": "2017-02-11 5:47"
},
"current": {
"last_updated_epoch": 1486792043,
"last_updated": "2017-02-11 05:47",
"temp_c": 0.0,
"temp_f": 32.0,
"is_day": 0,
"condition": {
"text": "Mist",
"icon": "//cdn.apixu.com/weather/64x64/night/143.png",
"code": 1030
},
"wind_mph": 8.1,
"wind_kph": 13.0,
"wind_degree": 330,
"wind_dir": "NNW",
"pressure_mb": 1019.0,
"pressure_in": 30.6,
"precip_mm": 0.0,
"precip_in": 0.0,
"humidity": 74,
"cloud": 0,
"feelslike_c": -4.0,
"feelslike_f": 24.8
}
}
創建外部表命令下面給出:
CREATE EXTERNAL TABLE weatherdata (
location STRUCT<
name:STRING,
region:STRING,
country:STRING,
lat:FLOAT,
lon:FLOAT,
tz_id:STRING,
localtime:STRING>,
current STRUCT<
last_updated_epoch:BIGINT,
last_updated:STRING,
temp_c:FLOAT,
temp_f:FLOAT,
is_day:INT,
condition:STRUCT<text:STRING, icon:STRING, code:INT>,
wind_mph:FLOAT, wind_kph:FLOAT,
wind_degree:INT,
wind_dir:STRING,
pressure_mb:FLOAT,
pressure_in:FLOAT,
precip_mm:FLOAT,
precip_in:FLOAT,
humidity:INT,
cloud:INT,
feelslike_c:FLOAT,
feelslike_f:FLOAT>
)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe';
我得到以下錯誤:
FAILED: ParseException line 9:3 cannot recognize input near 'current' 'STRUCT' '<' in column specification
我試圖創建這個外部表的字段'當前'爲'curr'只是爲了檢查並且表已成功創建。很明顯,在將上面給出的'json'數據加載到該表中時,只有'位置'數據成功加載,'當前'數據顯示爲空。 「當前」是蜂巢中的關鍵字嗎?什麼是問題? 請幫忙解決這個問題。
你'條件:STRUCT',那麼爲什麼沒有':''上或location''current'? –
@ cricket_007':'僅用於內部結構變量。 –