Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

impala Shell


May 26, 2021 impala


Table of contents


In the previous sections, we've seen installing Impala using cloudera and its architecture.

  • Impala shell (command prompt)
  • Hue (user interface)
  • ODBC and JDBC (third-party libraries)

This chapter describes how to launch the various options for Impala Shell and Shell.

Impala Shell command reference

Impala shell's commands are divided into general commands that query specific options, as well as table and database-specific options, as described below.

Universal command

  • help
  • version
  • history
  • shell (or) !
  • connect
  • exit | quit

Query specific options

  • Set/unset
  • Profile
  • Explain

Table and database-specific options

  • Alter
  • describe
  • drop
  • insert
  • select
  • show
  • use

Start impala shell

Open the cloudera terminal, log in as a super user, and type cloudera as your password, as shown below.

[cloudera@quickstart ~]$ su
Password: cloudera
[root@quickstart cloudera]#

Start Impala shell by typing the following command -

[root@quickstart cloudera] # impala-shell 
Starting Impala Shell without Kerberos authentication 
Connected to quickstart.cloudera:21000 
Server version: impalad version 2.3.0-cdh5.5.0 RELEASE 
(build 0c891d79aa38f297d244855a32f1e17280e2129b)
********************************************************************* 

Welcome to the Impala shell. Copyright (c) 2015 Cloudera, Inc. All rights reserved.
(Impala Shell v2.3.0-cdh5.5.0 (0c891d7) built on Mon Nov 9 12:18:12 PST 2015)

Want to know what version of Impala you're connected to? Run the VERSION command to 
find out! 
********************************************************************* 
[quickstart.cloudera:21000] >

Impala - Universal command

Impala's general command is explained below -

Help command

Impala shell's help command provides a list of commands available in Impala -

[quickstart.cloudera:21000] > help;
 
Documented commands (type help <topic>):
========================================================
compute  describe  insert  set     unset  with  version
connect  explain   quit    show    values use
exit     history   profile select  shell  tip 
  
Undocumented commands:
========================================= 
alter create desc drop help load summary

The version command

The version command gives you the current version of Impala, as shown below.

[quickstart.cloudera:21000] > version;
Shell version: Impala Shell v2.3.0-cdh5.5.0 (0c891d7) built on Mon Nov 9 
12:18:12 PST 2015

Server version: impalad version 2.3.0-cdh5.5.0 RELEASE (build 
0c891d79aa38f297d244855a32f1e17280e2129b)

The history command

Impala's highstory command shows the last 10 commands executed in the shell. T he following is an example of a historical command. H ere we execute 5 commands, namely version, help, display, usage, and history.

[quickstart.cloudera:21000] > history;
[1]:version;
[2]:help;
[3]:show databases;
[4]:use my_db;
[5]:history;

Quit/exit command

You can use the quit or exit command to eject from the Impala shell, as shown below.

[quickstart.cloudera:21000] > exit; 
Goodbye cloudera

Connect command

The connect command is used to connect to a given instance of Impala. If no instance is specified, it will connect to the default port 21000, as shown below.

[quickstart.cloudera:21000] > connect; 
Connected to quickstart.cloudera:21000 
Server version: impalad version 2.3.0-cdh5.5.0 RELEASE (build 
0c891d79aa38f297d244855a32f1e17280e2129b)

Impala queries for specific options

Impala's query-specific command accepts queries. T hey explain below -

Description

The explain command returns the execution plan for a given query.

[quickstart.cloudera:21000] > explain select * from sample;
Query: explain select * from sample
+------------------------------------------------------------------------------------+ 
| Explain String                                                                     | 
+------------------------------------------------------------------------------------+ 
| Estimated Per-Host Requirements: Memory = 48.00MB VCores = 1                       | 
| WARNING: The following tables are missing relevant table and/or column statistics. |
| my_db.customers                                                                    | 
| 01:EXCHANGE [UNPARTITIONED]                                                        | 
| 00:SCAN HDFS [my_db.customers]                                                     | 
| partitions = 1/1 files = 6 size = 148B                                             | 
+------------------------------------------------------------------------------------+ 
Fetched 7 row(s) in 0.17s

Brief introduction

The profile command displays low-level information about the most recent query. T his command is used to query diagnostics and performance adjustments. T he following is an example of a profile command. In this case, the profile command returns low-level information that describes the query.

[quickstart.cloudera:21000] > profile;

Query Runtime Profile: 
Query (id=164b1294a1049189:a67598a6699e3ab6): 

   Summary: 
      Session ID: e74927207cd752b5:65ca61e630ad3ad
      Session Type: BEESWAX 
      Start Time: 2016-04-17 23:49:26.08148000 End Time: 2016-04-17 23:49:26.2404000 
      Query Type: EXPLAIN 
      Query State: FINISHED 
      Query Status: OK 
      Impala Version: impalad version 2.3.0-cdh5.5.0 RELEASE (build 0c891d77280e2129b) 
      User: cloudera 
      Connected User: cloudera 
      Delegated User: 
      Network Address:10.0.2.15:43870 
      Default Db: my_db 
      Sql Statement: explain select * from sample 
      Coordinator: quickstart.cloudera:22000 
      : 0ns 
      Query Timeline: 167.304ms 
         - Start execution: 41.292us (41.292us) - Planning finished: 56.42ms (56.386ms) 
         - Rows available: 58.247ms (1.819ms) 
         - First row fetched: 160.72ms (101.824ms) 
         - Unregister query: 166.325ms (6.253ms)
         
   ImpalaServer: 
      - ClientFetchWaitTimer: 107.969ms 
      - RowMaterializationTimer: 0ns

Table and database-specific options

The following table lists table and data-specific options in Impala.

Sr.No commanding explanation
1

Alter

The alter command is used to change the structure and name of the table in Impala.

2

Describe

Impala's describe command provides the table's metadata. I t contains information such as columns and their data types. T he describe command has desc as a shortcut.

3

Drop

Drop commands are used to remove constructs from Impala, where the constructs can be tables, views, or database functions.

4

insert

Impala's insert command is used

  • Attach data (columns) to the table.
  • Overrides the data for an existing table.
  • Overrides the data for an existing table.

5

select

Select statements are used to perform the required actions on a particular dataset. I t specifies the dataset on which to complete certain operations. Y ou can print or store the results of select statements (in a file).

6

show

Impala's show statements are used to display relays for various constructs, such as tables, databases, and tables.

7

use

Impala's use statement is used to change the current context to the desired database.