Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hive, how to get column name when output the query (and not table_name.column_name)

Using Hive I would like to get the result of a query inside a csv file, I would also like to get the header.

To achieve this I'm executing:

hive -e '
    use database;
    set hive.cli.print.header=true;
    select * from table;
' > /home/centos/user/result.csv

But the first line of the csv is:

table.field1_name,table.field2_name,table.field3_name

How can I get insead:

field1_name,field2_name,field3_name
like image 763
user3636476 Avatar asked Dec 07 '22 23:12

user3636476


1 Answers

I just needed to add:

set hive.resultset.use.unique.column.names=false;
like image 120
user3636476 Avatar answered May 14 '23 05:05

user3636476