在hive查詢中我們發現hive的查詢輸出不顯示列名,怎么解決呢?
解決辦法:進入hive cli后: set hive.cli.print.header=true;
hive> select * from ratings limit 5;
OK
ratings.userid ratings.movieid ratings.rating ratings.timestamped
1 1193 5.0 978300760
1 661 3.0 978302109
1 914 3.0 978301968
1 3408 4.0 978300275
1 2355 5.0 978824291
Time taken: 0.1 seconds, Fetched: 5 row(s)
此時顯示的字段名帶表名,可讀性很差,繼續在hive cli中:set hive.resultset.use.unique.column.names=false;
hive> set hive.resultset.use.unique.column.names=false;
hive> select * from ratings limit 5;
OK
userid movieid rating timestamped
1 1193 5.0 978300760
1 661 3.0 978302109
1 914 3.0 978301968
1 3408 4.0 978300275
1 2355 5.0 978824291
Time taken: 0.103 seconds, Fetched: 5 row(s)
OK!!!
因為在cli中set配置屬性只是當次有效,如果想永久配置的話,將上述命令配置到hive/conf下的配置文件中,或者配置到hiverc文件里,因為每次CLI啟動時,在提示符出現之前,Hive會自動在HOME目錄下查找名為.hiverc的文件,而且執行這個文件中的所有命令。非常適合做初始化,所以有些關於hive的初始化設置可以配置到家目錄下的.hiverc文件里。