Support Questions

Find answers, ask questions, and share your expertise

Convert select query output to CSV from beeline or impala-shell

avatar
Expert Contributor

Hello,

 

We are using a beeline or impala-shell to extract data from hive tables as per requirement from the end-user. However, the request for data extraction is for high records for more than 1000 or sometimes more than 3000. It is very tedious to extract using the select query and dump to excel sheet.

 

Is there any alternative way to take the output in a CSV file?.

 

Like the output of select query moves to CSV file. 

 

Please suggest.

1 ACCEPTED SOLUTION

avatar
Expert Contributor

@HanzalaShaikh 

 

impala-shell -i <hostlb/impaladhost>:<impala-shell port> -d <db-name> -k -q

--ssl --ca_cert=<ca-cert path>

"query" -o /path/to/file.csv -B

 

//Sample shell command from my test bed

impala-shell -i host-10-17-102-166.coe.cloudera.com:25003 -d test_database -k --ssl --ca_cert=/opt/cloudera/security/cacert.pem -q "select * from salerecord limit 20" -o output.txt -B

 

Can you try the above with the updated configurations from your environment and let me know if this addresses your query.

View solution in original post

2 REPLIES 2

avatar
Expert Contributor

@HanzalaShaikh 

 

impala-shell -i <hostlb/impaladhost>:<impala-shell port> -d <db-name> -k -q

--ssl --ca_cert=<ca-cert path>

"query" -o /path/to/file.csv -B

 

//Sample shell command from my test bed

impala-shell -i host-10-17-102-166.coe.cloudera.com:25003 -d test_database -k --ssl --ca_cert=/opt/cloudera/security/cacert.pem -q "select * from salerecord limit 20" -o output.txt -B

 

Can you try the above with the updated configurations from your environment and let me know if this addresses your query.

avatar
Expert Contributor

Hi Tushar

Thanks a lot for your quick reply. The resolution you provided has worked. I am accepting it as a solution.

 

Thanks once again.