2016-08-13 75 views
0

我正在嘗試將文件導入配置單元。 的樣品數據如下配置單元未取值

1::Toy Story (1995)::Animation|Children's|Comedy 
2::Jumanji (1995)::Adventure|Children's|Fantasy 
3::Grumpier Old Men (1995)::Comedy|Romance 
4::Waiting to Exhale (1995)::Comedy|Drama 

我的表聲明如下

create table movies(id int,title string,genre string) row format delimited fields terminated by '::'; 

但加載數據後,我的表顯示的數據僅前兩個字段。

Total MapReduce CPU Time Spent: 1 seconds 600 msec 
OK 
1  Toy Story (1995)  
2  Jumanji (1995) 
3  Grumpier Old Men (1995) 
4  Waiting to Exhale (1995)  
Time taken: 22.087 seconds 

任何人都可以幫助我,爲什麼發生這種情況或如何調試。

回答

0

蜂巢行分隔符將默認只需要一個字符,因爲你有兩個字符 '::',請嘗試用MultiDelimitSerDe

查詢創建表:

CREATE TABLE movies (id int,title string,genre string) ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe' 
WITH SERDEPROPERTIES ("field.delim"="::") 
STORED AS TEXTFILE; 

輸出:

hive> select * from movies; 
OK 
1 Toy Story (1995) Animation|Children's|Comedy 
2 Jumanji (1995) Adventure|Children's|Fantasy 
3 Grumpier Old Men (1995) Comedy|Romance 
4 Waiting to Exhale (1995) Comedy|Drama 

請參照相似的文章: Load data into Hive with custom delimiter