Impala Export Query Results to file

Source: Internet
Author: User
Tags ldap first row port number

To export the results of the query to a local file using the Impala-shell command line, take it for granted that Impala and hive can use the Insert overwrite local directory '/home/test.txt ' Select .... Such commands are exported locally, executed a bit, and found that Impala does not support this.

Then I looked up and found that Impala-shell can export query results to a file in the same way as MySQL. Take parameters at the command line, for example:

Impala-shell-q  "select * FROM table Limit"-B--output_delimiter= "\ T"-O testimpalaoutput.txt

Impala-shell There are many other parameters, you can impala-shell-h view, the following is someone else's translation, copy come for your reference:

Options

Description

-B or–delimited

Causes the query results to be printed in plain text format using delimiter splitting. Useful when generating data for other Hadoop components. Useful for avoiding the performance overhead of neatly printing all output, especially when using a query to return a large number of result sets for benchmarking. Use the –output_delimiter option to specify a separator character. Using the-B option is often used to save all query results to a file instead of printing to the screen. Add in Impala 1.0.1

–print_header

Whether to print the column name. When you print neatly, it is enabled by default. When the-B option is used, the column name is printed on the first row

-o filename or–output_file filename

Saves all query results to the specified file. Typically used to save query results when executing a single query using the-q option at the command line. The same is true for interactive sessions, where you'll only see how many rows of data are fetched, but you don't see the actual dataset. When the-Q and-O options are used in combination, error messages are automatically output to the/dev/null (to suppress these incidental messages when combining the-q and-o options, Redire CT stderr to/dev/null). Add in Impala 1.0.1

–output_delimiter=character

When you use the-B option to print a query result in plain file format, the delimiter between fields is specified (specifies the character to use as a delimiter between field when query results is P Rinted in plain format by the-b option). The Default is Tab tab (' \ t '). If a delimiter is included in the output, the column is generated and/or escaped (if an output value contains the delimiter character, which field is quoted and/or escaped). Add in Impala 1.0.1

-P Or–show_profiles

For each query executed in the shell, displays more detailed information about the execution steps of its query execution plan (same as the output of the EXPLAIN statement) and the low-level failure (low-level breakdown)

-H Or–help

Display Help information

-I. Hostname or–impalad=hostname

Specifies the host on which the Impalad daemon is running. The default port is 21000. You can connect to any host running Impalad in the cluster. If you connect to a Impalad instance using a different port through the –FE_PORT flag, you should provide the port number in the format Hostname:port

-Q Query Or–query=query

Pass a query or other shell command from the command line. The shell exits immediately after executing this statement. Limit to a single statement, which can be a SELECT, CREATE TABLE, SHOW TABLES, or other Impala-shell-approved statement. Because the USE statement cannot be passed together with other queries, for tables other than the default database, you should precede the table name with a database identifier (or pass a file with the-F option that contains the USE statement and other queries)

-F Query_file Or–query_file=query_file

Passes a SQL query in a file. File contents must be separated by semicolons

-K Or–kerberos

Kerberos authentication is used when connecting to Impalad. An error is displayed if the Impalad instance that you are connecting to does not support Kerberos

-S Kerberos_service_name or–kerberos_service_name=name

Instructs Impala-shell to authenticate to a particular Impalad service principal. If Kerberos_service_name is not set, Impala is used by default. How to enable this option, while attempting to establish a connection that does not support Kerberos, returns an error if this option was used in conjunction with a connection in which Kerberos was not su pported, Errors is returned)

-V Or–verbose

Enable verbose output

–quiet

Close verbose output

-V Or–version

Display version Information

-C

Continue execution when query execution fails

-R Or–refresh_after_connect

Refreshes the Impala metadata after a connection is established and performs the same effect as the Refresh statement after the connection is established

-D default_db or–database=default_db

Specifies the database to use after startup, using the USE statement to select the database after the connection is established, and, if not specified, using the default database

-L Enable LDAP Authentication
-U When LDAP authentication is enabled with the-l option, a user name is provided (using the short user name instead of the full LDAP distinguished name (distinguished name)) and the shell prompts for the password

Parameter contents are referenced from:
https://my.oschina.net/weiqingbin/blog/190929

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.