To export hive data to csv I use the following script:
note that this is just a example:
#!/bin/bash
hive -e "insert overwrite local directory '/tmp/'
row format delimited fields terminated by ','
select * from Mydatabase,Mytable limit 10"
> /tmp/table.csv
I get a csv file in the local path: /tmp/, it looks like :
2017-07-04 12:58:05.0,MB0_CLI_2,29353,0982,SAIE,MNIT-BM,-,-
2017-07-04 12:56:07.0,MBUD00_CLI_2,629353,662982,SAE,MBEINIT-BM,-,-
2017-07-04 12:56:46.0,MBUDLI_2,618,65530,SAISIE,MBUIT-BA,-,-
2017-07-04 12:56:13.0,82_CLI_3,65082954,47857,UNAGE,-,PARERS,-
2017-07-04 12:56:05.0,822I_3,654,857,UNDGE,-,PAIRS,-
2017-07-04 12:59:28.0,823,65084,6926461,UNDNED_AAGE,-,PLIERS,-
2017-07-04 12:59:05.0,82200_CLI_3,65954,69461,UNNED_AFAGE,-,PULIERS,-
2017-07-04 12:56:46.0,MBUDLI_2,618,65530,SAISIE,MBUIT-BA,-,-
2017-07-04 12:56:13.0,82_CLI_3,65082954,47857,UNAGE,-,PARERS,-
2017-07-04 12:56:46.0,MBUDLI_2,618,65530,SAISIE,MBUIT-BA,-,-
The problem is that the csv file doesn't import the head of each column
how can I export hive table into csv file with the head of columns?