Impala-shell
インパラ-シェル
前の章では、clouderaとそのアーキテクチャを使用したImpalaのインストールを見てきました。
- Impalaシェル(コマンドプロンプト)
- 色相(ユーザーインターフェイス)
- ODBCおよびJDBC(サードパーティライブラリ)
この章では、Impalaシェルの起動方法とシェルのさまざまなオプションについて説明します。
Impalaシェルコマンドリファレンス
Impalaシェルのコマンドは、以下で説明するように、一般的なコマンド、クエリ固有のオプション、*テーブルとデータベース固有のオプション*に分類されます。
一般的なコマンド
- help
- バージョン
- 歴史
- シェル(または)!
- 接続する
- 出口|終了する
クエリ固有のオプション
- 設定/設定解除
- プロフィール
- 説明する
テーブルおよびデータベース固有のオプション
- 変更する
- 記述する
- drop
- インサート
- 選択する
- show
- use
Impalaシェルの起動
以下に示すように、clouderaターミナルを開き、スーパーユーザーとしてサインインし、パスワードとして cloudera を入力します。
[cloudera@quickstart ~]$ su
Password: cloudera
[root@quickstart cloudera]#
次のコマンドを入力してImpalaシェルを起動します-
[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 –汎用コマンド
Impalaの汎用コマンドを以下に説明します-
ヘルプコマンド
Impalaシェルの help コマンドは、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
バージョンコマンド
以下に示すように、 version コマンドはImpalaの現在のバージョンを提供します。
[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)
履歴コマンド
Impalaの history コマンドは、シェルで実行された最後の10個のコマンドを表示します。 以下は history コマンドの例です。 ここでは、バージョン、ヘルプ、表示、使用、および履歴の5つのコマンドを実行しました。
[quickstart.cloudera:21000] > history;
[1]:version;
[2]:help;
[3]:show databases;
[4]:use my_db;
[5]:history;
終了/終了コマンド
以下に示すように、 quit または exit コマンドを使用して、Impalaシェルから抜けることができます。
[quickstart.cloudera:21000] > exit;
Goodbye cloudera
接続コマンド
*connect* コマンドは、Impalaの特定のインスタンスに接続するために使用されます。 インスタンスを指定しない場合、以下に示すようにデフォルトのポート *21000* に接続します。
[quickstart.cloudera:21000] > connect;
Connected to quickstart.cloudera:21000
Server version: impalad version 2.3.0-cdh5.5.0 RELEASE (build
0c891d79aa38f297d244855a32f1e17280e2129b)
Impalaクエリ固有のオプション
Impalaのクエリ固有のコマンドはクエリを受け入れます。 以下に説明します-
説明する
*explain* コマンドは、指定されたクエリの実行プランを返します。
[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
プロフィール
*profile* コマンドは、最近のクエリに関する低レベルの情報を表示します。 このコマンドは、クエリの診断とパフォーマンスチューニングに使用されます。 以下は *profile* コマンドの例です。 このシナリオでは、 *profile* コマンドは *explain* クエリの低レベル情報を返します。
[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
テーブルおよびデータベース固有のオプション
次の表に、Impalaのテーブルおよびデータ固有のオプションを示します。
Sr.No | Command & Explanation |
---|---|
1 |
|
2 |
Describe Impalaの describe コマンドは、テーブルのメタデータを提供します。 列やデータ型などの情報が含まれています。 describe コマンドには、ショートカットとして desc があります。 |
3 |
Drop
|
4 |
insert Impalaの*挿入*コマンドを使用して、
|
5 |
|
6 |
show Impalaの show ステートメントは、テーブル、データベース、テーブルなどのさまざまな構造のメタストアを表示するために使用されます。 |
7 |
use Impalaの use ステートメントを使用して、現在のコンテキストを目的のデータベースに変更します。 |