【hive】使用load inpath导入数据时出现NULL原因解析
2015-06-02 14:31
459 查看
在把hdfs上数据迁移到hive中的表时,若出现数据位NULL,是因为没有指定列分隔符。
由于hive默认的分隔符是/u0001(Ctrl+A),为了平滑迁移,需要在创建表格时指定数据的分割符号,语法如下:
[sql] view
plaincopyprint?
hive (default)> create external table et (time BIGINT, userid string, content string, urlrank int, urlnum int, url string)
> partitioned by (filenum int)
> row format delimited fields terminated by '\t';
上面创建的是外部表,“导入”数据时可以用load:
[sql] view
plaincopyprint?
load data local inpath '/input/SogouQueryLog/file1'
overwrite table et partition (filenum=1);
但若不想进行移动数据,就用命令alter来进行指向:
[sql] view
plaincopyprint?
alter table et add partition (filenum=1) location '/input/SogouQueryLog/file1';
注意location后面跟的地址必须是个目录,若不是,可以用hdfs fs -mv src dest 进行移动数据:
[sql] view
plaincopyprint?
hadoop fs -mv /input/SogouQueryLog/querylog_1 /input/SogouQueryLog/file1
由于hive默认的分隔符是/u0001(Ctrl+A),为了平滑迁移,需要在创建表格时指定数据的分割符号,语法如下:
[sql] view
plaincopyprint?
hive (default)> create external table et (time BIGINT, userid string, content string, urlrank int, urlnum int, url string)
> partitioned by (filenum int)
> row format delimited fields terminated by '\t';
上面创建的是外部表,“导入”数据时可以用load:
[sql] view
plaincopyprint?
load data local inpath '/input/SogouQueryLog/file1'
overwrite table et partition (filenum=1);
但若不想进行移动数据,就用命令alter来进行指向:
[sql] view
plaincopyprint?
alter table et add partition (filenum=1) location '/input/SogouQueryLog/file1';
注意location后面跟的地址必须是个目录,若不是,可以用hdfs fs -mv src dest 进行移动数据:
[sql] view
plaincopyprint?
hadoop fs -mv /input/SogouQueryLog/querylog_1 /input/SogouQueryLog/file1
相关文章推荐
- eclipse.ini内存设置
- [PHP问题]Cannot redeclare xxxxxx() (previously declared in C:\WWW\xxx.xxx:xxx)
- HttpClient状态码大全
- 工作周报041
- 大端小端格式详解
- apache 安装/mod_dir.so: undefined symbol: apr_array_clear
- java起源和基本数据类型
- assert使用场景
- android DecorView 浅析
- 想靠写代码吃饭 这些你一定要会
- ubuntu 的开机自启动文件
- 玩转单元测试之WireMock -- Web服务模拟器
- ORTP库的使用
- C++头加using namespace std的原因
- JavaScript特性三:this关键字
- 关于大型网站技术演进的思考(三)--存储的瓶颈(3)
- LeetCode_8---String to Integer (atoi)
- 搭建CA,二级CA,和签发证书
- Socket与URL通信比较
- Android 之 Window、WindowManager 与窗口管理