码迷,mamicode.com
首页 > 其他好文 > 详细

【转】hive导入数据出现NULL

时间:2015-07-14 17:19:06      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

在把hdfs上数据迁移到hive中的表时,若出现数据位NULL,是因为没有指定列分隔符。

由于hive默认的分隔符是/u0001(Ctrl+A),为了平滑迁移,需要在创建表格时指定数据的分割符号,语法如下:

 

  1. hive (default)> create external table et (time BIGINT, userid string, content string, urlrank int, urlnum int, url string)  
  2.               > partitioned by (filenum int)   
  3.               > row format delimited fields terminated by ‘\t‘; 

 

上面创建的是外部表,“导入”数据时可以用load,但若不想进行移动数据,就用命令alter来进行指向:

 

  1. alter table et add partition (filenum=1) location ‘/input/SogouQueryLog/file1‘;  

注意location后面跟的地址必须是个目录,若不是,可以用hdfs fs -mv src dest 进行移动数据:

 

 

  1. hadoop fs -mv /input/SogouQueryLog/querylog_1 /input/SogouQueryLog/file1

【转】hive导入数据出现NULL

标签:

原文地址:http://www.cnblogs.com/zhengrunjian/p/4645600.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!