Impala-shell command-line options with brief explanations

Impala-shell can be launched with other optional parameters to either perform a specific action or to provide more information about the action. These command line options are used along with the impala-shell command as a parameter. Some of these options are created to provide assistance with impala-shell usage, while others are designed to perform a specific action. For example, the –q or –query option can run a query directly outside the shell and show the output directly on console windows, as shown in the following screenshot:

Impala-shell command-line options with brief explanations

Another example is to use the –d option with a specific database name, as shown in the following screenshot. Once impala-shell starts, it connects to impalad at localhost through the default port 21000 and uses the selected database. In the shell we can call any command specific to the database used, which is also shown in the following screenshot:

Impala-shell command-line options with brief explanations

The syntax to use the command-line option is shown in the following two examples:

$ impala-shell –q 'select * from mytable;'
$ impala-shell –d students

In the next few sections, we will learn more about these command-line options within their specific category.

General command-line options

In this section, we will learn about a few command options, which can be used to get help about Impala-shell or to get the version along with other general details. A list of general commands are listed in the following table:

Command option

Description

-h or --help

This option prints the impala shell help details as console output. You can use this option as follows:

$ impala-shell –h or $impala-shell --h elp

-v or --version

These options print the current running impala-shell version and you can use this option as follows:

$impala-shell –v or $impala-shell –version

An example of using the –v option is as follows:

$ impala-shell -v
Impala Shell v1.1.1 (83d5868) built on Fri Aug 23 17:28:05 PDT 2013

-V or --verbose

This option enables the verbose output mode, so you will see lot more information in your output.

--quiet

This option disables the verbose output mode.

-c

This option continues command execution even when query failure occurs. This option is useful when multiple queries are submitted via shell scripts or other means, and processing does not stop if one or more queries return failure.

Connection-specific options

These command options can be use to connect specific impalad located remotely or to connect a specific database after starting impala-shell. A list of connection-specific command options is in the following table:

Command option

Description

-I hostname or –impalad=hostname

This option connects impala-shell to impalad, using a specific host-passed hostname. By default, connection is made on port 21000; however, a different port number can be passed with the hostname as hostname:port. This command is useful when impala-shell is connected to such an impala daemon, which is running on a machine other than the current machine running impala-shell. You can use this command as follows:

$impala-shell –l myhostname:21005

-r or –refresh_after_connect

This option refreshes Impala metadata after successful connection. This option is the same as applying the REFRESH statement after connecting to the Impala server. You can use this command to refresh metadata just after connecting to impalad as follows:

$impalad –r 

-d database_name or –database database_name

By default, when impala-shell starts and connects to the Impala server, it connects to a database named default. Using this option, you can pass a desired database name to be used as the default after a successful connection. If you have a database named logs and want to use it with impala-shell, you will achieve your objective by using the following command:

$impala-shell –d logs

Query-specific options

These commands are specific to passing queries with the impala-shell command. Once you use such a command option, the query result can be saved to a file outside impala-shell or can be printed on the console, depending on your choice. A list of query-specific command options is shown in the following table:

Command option

Description

-q query or –query=query

This option allows you to issue a single query directly from a command line. This option is most useful when you have a need to run impala-shell inside a programming language such as Python or Perl, or inside a shell script.

If launched from the shell script, the query output will be displayed on the console or can be collected through the programming interface, if used. An example of using this option is as follows:

$ impala-shell –query ''select * from table_name;'

-o filename or --output_file filename

This option allows you to save the query output to a file.

-B or --delimited

This option is use to produce comma-separated, tab-separated, or other delimited text files as output. The default delimiter is the TAB character ( ); however, it can be changed using the –output_delimiter option and passing the desired delimiter character.

-f query_file_name or –query_file=query_file_name

Using this option you can pass a SQL query file that includes all of the queries you want to pass through impala-shell. An example of using this option is as follows:

$impala-shell –f myqueryfile.sql

-p or --show_profiles

This option is similar to the SQL EXPLAIN statement that provides a query-execution plan including detailed query execution steps for every query executed by the impala-shell

Secure connectivity-specific options

If configured correctly, you can pass the appropriate command-line options shown in the following table, to use these security options while connecting impalad from impala-shell.

Command options

Description

-k or --kerberos

When using this option, the impala-shell connects to impalad using the Kerberos authentication. Make sure to have the Kerberos authentication enabled and working with impalad, otherwise a connection cannot be established and errors will be displayed.

-s Kerberos_service_name or –kerberos_service_name=Kerberos_service_name

This option instructs impala-shell to connect to impalad using a particular impalad service principal, as passed in the option. If Kerberos_service_name is not specific, Impala is used by default with Kerberos.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.249.198