hive查詢表,返回結果是null

2022-06-15 22:12:28 字數 766 閱讀 8962

問題: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;

oknull 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;

ok1 tom

2 lili

綜上所述:hive 中建立表載入資料的時候,分隔符與載入檔案中的分隔符需要一致,才能得到正確的查詢結果.

Hive查詢表,返回資料全是NULL

情況1 hive create table users id int,name string hive load data local inpath usr local users.txt into table users 其中 usr local users.txt 的內容為下面所示,每一行的 i...

ibatis 查詢返回結果為map

ibatis裡面result只有3種,resultmap,resultclass,resultsettype,沒有resulttype mybatis的 研究了下手冊,發現返回map的方式如下 select sum si.balance qty balance qty s sum si.reserv...

hive表查詢 排序

1.全域性排序 order by 使用orderby對全域性進行排序的前提是只能有乙個reduce。order by asc公升序,order by desc降序。order by 列別名 按照別名公升序排序 order by 列名1 列名2 先按照列名1的公升序排序,如果相等再按照列名2進行排序 ...