Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove table names from column names in beeline query results

I am saving beeline query output to a csv file. However the column names in the csv files contain the table name too. For example if table name is sales and col name is Date then csv has sales.Date as the column name. I googled around and found a very good solution in Stack overflow Hive - How to display Hive query results in the Command Line along with column names

I tried doing below from hive terminal and it works.

set hive.resultset.use.unique.column.names=false;

However when I try saving the file to csv from command line it still puts the table name in column names.

Is there any way to avoid that?

Query used from CLI:-

bee_line --outputformat=csv2 --showHeader=true --silent=true -e "select * from salesdata.ales" >path-to-csv

where bee_line is an alias for full connection string stored in bash profile.

like image 620
itthrill Avatar asked Nov 18 '25 09:11

itthrill


1 Answers

You can set hive properties as arguments to beeline using the --hiveconf option.

Your command would look like,

bee_line --hiveconf hive.resultset.use.unique.column.names=false -outputformat=csv2 --showHeader=true --silent=true -e "select * from salesdata.ales" >path-to-csv

Note: Restricted properties cannot be passed to this option.

like image 89
franklinsijo Avatar answered Nov 21 '25 02:11

franklinsijo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!