问题:hive查询表,返回结果都是null

hive> create table testTable(id int, name string);

hive> load data local inpath '/home/test.txt' into table testTable;

其中“/home/test.txt”的内容为下面所示,每一行的(id,name)之间使用一个空格分割。

1 tom
2 lili

hive> select * from users;
OK
NULL NULL
NULL NULL

解决办法:

hive> create table testTable(id int, name string);

改为:

hive> CREATE TABLE testTable(id int, name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ' LINES TERMINATED BY '\n' STORED AS TEXTFILE;

其中TERMINATED BY ' '指定了数据分隔符是一个空格,与“/home/test.txt”中每行分隔符一致。

hive> select * from new_test;
OK
1 tom
2 lili

综上所述:hive 中创建表加载数据的时候,分隔符与加载文件中的分隔符需要一致,才能得到正确的查询结果.

最新文章

  1. 第二天--html
  2. mysql 怎么查询出,分组后的总条数。。。也就是有多少组数。。。。怎么写
  3. centos6.5安装mysql记录
  4. [Javascript] Promise-based functions should not throw exceptions
  5. 关于 iOS10 更新后 360 云盘 的上传按钮消失的解决方案
  6. C#中 ? 和?? 的用法
  7. javaweb学习总结十一(JAXP对XML文档进行DOM解析)
  8. oracle的function和procedure返回值给shell
  9. 关于Adobe Flash 11.3 引起的火狐使用问题
  10. angularJS环境安装
  11. Java凝视Annotation
  12. nginx参数的详细说明
  13. python开发之virtualenv与virtualenvwrapper讲解
  14. 7I - 数塔
  15. Django聚合与分组查询中value与annotate的顺序问题
  16. F800上的CPU有多少个core?
  17. python金融与量化分析------Matplotlib(绘图和可视化)
  18. Linux 双网卡配置两个IP同时只有一个会通的原因
  19. Java虚拟机--虚拟机字节码执行引擎
  20. ASP.Net中关于WebAPI与Ajax进行跨域数据交互时Cookies数据的传递

热门文章

  1. PHP经常使用正則表達式汇总
  2. mac使用git管理Github
  3. linux 自启动
  4. svn Couldn't open rep-cache database
  5. connect()
  6. eclipse + MinGW调试程序printf输出被buffer的问题
  7. oracle怎么卸载
  8. Web里URL空格的转换方法
  9. ASP.NET动态网站制作(25)-- ADO.NET(4)
  10. Error:“const char*”类型的实参与“wchar_t”类型的形参不兼容