Reputation: 2618
I am working in Hive for quite a while . Please note that I don't use Hue at all. I use the Hive shell all the time and now I got a weird but useful question.
Whenever we execute a query in the Hive shell, we can see the relevant results on screen but we cannot recognise the column names corresponding to the data unless we do a "desc formatted table_name" or any other similar command and scroll up / down the screen to match the results with the table structure. We do this all the time most probably.
Just out of curiosity I want to know whether is there any way to print the column names along with the data atleast when we execute a basic query such as "select * from table_name" ?
Upvotes: 4
Views: 12663
Reputation: 31460
set this property once you open hive session
hive> set hive.cli.print.header=true;
so that it will display your column names.
Example:
hive> desc sales;
OK
col_name data_type comment
year string
month string
customer string
stateid string
productid string
qty string
billed string
hive> select * from sales;
OK
2011 1.2 A 2 1 2 8
2011 5.2 C 3 1 1 8
2011 2 B 1 2 1 2
2011 3 B 1 2 2 2
once i set the above property
hive> set hive.cli.print.header=true;
hive> select * from sales;
OK
sales.year sales.month sales.customer sales.stateid sales.productid sales.qty sales.billed
2011 1.2 A 2 1 2 8
2011 5.2 C 3 1 1 8
2011 2 B 1 2 1 2
if you want to get rid of table name i.e sales. before each column name then set the below property
hive> set hive.resultset.use.unique.column.names=false;
hive> select * from sales;
OK
year month customer stateid productid qty billed
2011 1.2 A 2 1 2 8
2011 5.2 C 3 1 1 8
2011 2 B 1 2 1 2
(or)
As a permanent solution,you can find and change this property value to true in your hive-site.xml.
Upvotes: 7