Similar to traditional relational systems, it is possible to export the results of the query to a file in Apache Impala. This can be with or without the formatting and with or without the delimitation being specified. Below is the syntax.
impala-shell -i servername:portname -B -q ‘select * from table’ -o filename ‘–output_delimiter=\delimiter’
Examples:
The below command export the contents of the table into a file.
impala-shell -i quickstart.cloudera:21000
-d dbtest
-q ‘select * from region3’
-o region3results.csv
-d refers to database
-q refers to query
-o refers to output file name
The below command export the query results into a file in a specified format
impala-shell -i quickstart.cloudera:21000 -B
-d dbtest
-q ‘select * from region3’
-o region3results.csv
‘–output_delimiter=\t’
Look at the screenshots for better understanding.
Use the below command based on the Kerberos environment-
impala-shell -k -i quickstart.cloudera:21000 -B
-d dbtest
-q ‘select * from region3’
-o region3results.csv
‘–output_delimiter=\t’
Hope you like this post.
Stay in touch for more interesting updates.
One comment