Apache Impala – Export Query Results To A File

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

This slideshow requires JavaScript.

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.

This slideshow requires JavaScript.

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s