2017-03-08 95 views
-1

我嘗試運行了這麼長的時間能有人告訴我這段代碼是什麼問題,它 代碼: -以文本文件導入數據庫蜂巢

CREATE EXTERNAL TABLE samp_log 
(
ip String ,col1 String ,col2 String , date String , time_hour int ,time_min int 
,time_sec int ,zone int , request String , request_con String , resp_code int 
,resp_byte BIGINT , reference String , ext_reference String , col13 String 
,col14 String ,col15 String , col16 String ,col17 String 
) 
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe' 
WITH SERDEPROPERTIES ("field.delim"=" ,[,]") 
STORED AS TEXTFILE 

錯誤 - 驅動程序返回:1,錯誤: OK FAILED:執行錯誤, 從org.apache.hadoop.hive.ql.exec.DDLTask返回代碼1。無法 驗證SERDE: org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe

我還添加了蜂房的contrib的jar文件..

+0

什麼是蜂巢的版本? – franklinsijo

+0

hive-hcatalog 0.13.0 –

+1

'MultiDelimitSerde'只能從Hive-0.14.0獲得。 – franklinsijo

回答

0

使用RegexSerDe

https://cwiki.apache.org/confluence/display/Hive/GettingStarted#GettingStarted-ApacheWeblogData

這裏是一個POC:

create external table mytable 
( 
    ip  string 
    ,dt  string 
    ,tm  string 
    ,tz  string 
) 
    row format serde 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe' 
    with serdeproperties 
    (
     'input.regex' = '^(.*?) - - \\[(.*?):(.*?) (.*?)\\].*$' 
    ) 
    location '/tmp/mytable' 
; 

select * from mytable 
; 

+-----------------+-------------+------------+------------+ 
| mytable.ip | mytable.dt | mytable.tm | mytable.tz | 
+-----------------+-------------+------------+------------+ 
| 123.123.123.123 | 26/Apr/2000 | 00:23:48 |  -0400 | 
+-----------------+-------------+------------+------------+ 
+0

檢查更新的答案 –

+0

謝謝@duduMarkovitz –

+0

嘿在運行上面的這個commnad後,它給出了你所顯示的輸出,但是給出了其他命令如Select ip, dt從mytable等。 –