Impala-shell command reference

After you launch Impala shell, you can use Impala shell commands to perform specific tasks. You can also pass these commands to Impala shell using the –q option as an argument. Some of these commands are referenced from SQL-like syntax because they are passed to an impala daemon inside impala-shell as SQL-like statements. Inside Impala shell, all the commands must end with a semicolon, as a semicolon is used as a command termination sequence. In this section, we will cover most of these commands, which you can run directly on Impala shell as shown in following screenshot:

Impala-shell command reference

In the previous screenshot, as soon as Impala shell is ready, the show databases command is used to list all the databases. These shell commands are described next, within their specific section to provide better context around the commands, and to explain their specific usage.

General commands

You can use the following general commands inside impala-shell to perform the various actions described:

Command option

Description

help

You can get more information about the available shell commands using the help command. Alternatively, using help <command_name> provides command-specific help. Here is an example:

> help profile;
Prints the runtime profile of the last INSERT or SELECT query executed.

version

Using this command you can get impala-shell and Impala daemon version information. Following is the output of the version command:

Shell version: Impala Shell v1.1.1 (83d5868) built on Fri Aug 23 17:28:05 PDT 2013
Server version: impalad version 1.1.1 RELEASE (build 83d5868f005966883a918a819a449f636a5b3d5f)

history

Gives a list of all commands passed into impala-shell. The history list is stored in file name ~/.impalahistory. You can call this command inside impala-shell as follows:

> history;

shell or !

Using this command you can run a certain file system command inside impala-shell. For example if you want to see the current working directory or file listing in the folder where the Impala shell is running, you can use the commands as follows:

> !pwd;
> ! ls –l;

refresh

Use this command to refresh impala metadata. This command is the same as the REFRESH command.

connect

Use this command to connect Impala shell with impalad on the remote host and the default port, 21000. If the port is not 21000, then pass the port number along with hostname as hostname:port.

exit/quit

You can use this command to exit from Impala shell.

Query-specific commands

Your primary objective is to use the Impala shell to perform query operations, and in this section we can see a few of those query commands with their examples:

Command option

Description

set/unset

Use this command to manage query options for the current Impala shell session; use set to include query options and unset to remove them. Mostly, the set command is used with specific options for fine tuning or troubleshooting the queries.

To set DEFAULT_ORDER_BY_LIMIT to 10, you can use the set command as follows:

> set default_order_by_limit=10;

Now, running the set command in the Impala shell returns the current set query option, as shown in the following commands:

> set;
Default query options:
  NUM_SCANNER_THREADS: 0
  ABORT_ON_DEFAULT_LIMIT_EXCEEDED: 0
  MAX_IO_BUFFERS: 0
  DEFAULT_ORDER_BY_LIMIT: -1
  BATCH_SIZE: 0
  NUM_NODES: 0
  DISABLE_CODEGEN: 0
  MAX_ERRORS: 0
  ABORT_ON_ERROR: 0
  MAX_SCAN_RANGE_LENGTH: 0
  ALLOW_UNSUPPORTED_FORMATS: 0
  SUPPORT_START_OVER: false
  DEBUG_ACTION: 
  MEM_LIMIT: 0
Query options currently set:
  DEFAULT_ORDER_BY_LIMIT: 10

To unset the value, just use the unset command as follows:

> unset default_order_by_limit;

profile

Using this command, you can get low-level information on the last processed query. You can use this command to fine-tune the query performance by understanding the output of this command. The same command can also be used for troubleshooting certain issues with the query. The command is as follows:

> profile;

explain

This command is similar to the EXPLAIN query command to provide an execution plan of a query. An example of using this command is as follows:

> explain select * from studentlist;
Query: explain select * from studentlist
Query finished, fetching results ...
+--------------------------------+
| Explain String                 |
+--------------------------------+
| PLAN FRAGMENT 0                |
|   PARTITION: UNPARTITIONED     |
|                                |
|   1:EXCHANGE                   |
|      tuple ids: 0              |
|                                |
| PLAN FRAGMENT 1                |
|   PARTITION: RANDOM            |
|                                |
|   STREAM DATA SINK             |
|     EXCHANGE ID: 1             |
|     UNPARTITIONED              |
|                                |
|   0:SCAN HDFS                  |
|      table=default.studentlist |
           #partitions=0 size=0B |
|      tuple ids: 0              |
+--------------------------------+
Returned 16 row(s) in 2.36s

Table- and database-specific commands

Now let's take a look at table- and database-specific commands (shown in the following table), which you can use inside the Impala shell to play with your databases and tables. I have explained these commands in great detail in the following chapters, so these commands are listed here only for reference.

Command option

Description

alter

Use this command to change the table structure or table settings.

describe

Use this command to see information about columns, column data types, and column comments for a specific table.

insert

Use this command to store query results into a table.

drop

Use this command to remove a schema object associated with a table or database.

select

Use this command to select a dataset that will process the action, the same as the SELECT statement.

use

Use this command to select a database that will be used to process a group of queries.

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

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