- 表特定語句
- Impala - 建立表語句
- Impala - 插入語句
- Impala - 選擇語句
- Impala - 描述語句
- Impala - 修改表
- Impala - 刪除表
- Impala - 截斷表
- Impala - 顯示錶
- Impala - 建立檢視
- Impala - 修改檢視
- Impala - 刪除檢視
- Impala - 子句
- Impala - ORDER BY 子句
- Impala - GROUP BY 子句
- Impala - HAVING 子句
- Impala - LIMIT 子句
- Impala - OFFSET 子句
- Impala - UNION 子句
- Impala - WITH 子句
- Impala - DISTINCT 運算子
- Impala 有用資源
- Impala - 快速指南
- Impala - 有用資源
- Impala - 討論
Impala - Shell
在前面的章節中,我們已經看到了使用 Cloudera 安裝 Impala 及其架構。
- Impala Shell(命令提示符)
- Hue(使用者介面)
- ODBC 和 JDBC(第三方庫)
本章解釋如何啟動 Impala Shell 以及 Shell 的各種選項。
Impala Shell 命令參考
Impala Shell 的命令分為通用命令、查詢特定選項和表和資料庫特定選項,如下所述。
通用命令
- help
- version
- history
- shell (或) !
- connect
- exit | quit
查詢特定選項
- Set/unset
- Profile
- Explain
表和資料庫特定選項
- Alter
- describe
- drop
- insert
- select
- show
- use
啟動 Impala Shell
開啟 Cloudera 終端,以超級使用者身份登入,並輸入cloudera作為密碼,如下所示。
[cloudera@quickstart ~]$ su Password: cloudera [root@quickstart cloudera]#
透過輸入以下命令啟動 Impala Shell:
[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 的通用命令:
help 命令
Impala Shell 的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 命令
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)
history 命令
Impala 的history命令顯示 Shell 中執行的最後 10 個命令。以下是history命令的示例。在這裡,我們執行了 5 個命令,即 version、help、show、use 和 history。
[quickstart.cloudera:21000] > history; [1]:version; [2]:help; [3]:show databases; [4]:use my_db; [5]:history;
quit/exit 命令
可以使用quit或exit命令退出 Impala Shell,如下所示。
[quickstart.cloudera:21000] > exit; Goodbye cloudera
connect 命令
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
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命令的示例。在這種情況下,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 中的表和資料特定選項。
| 序號 | 命令及說明 |
|---|---|
| 1 |
Alter alter命令用於更改 Impala 中表的結構和名稱。 |
| 2 |
Describe Impala 的describe命令提供表的元資料。它包含列及其資料型別的資訊。describe命令有desc作為快捷方式。 |
| 3 |
Drop drop命令用於從 Impala 中刪除構造,其中構造可以是表、檢視或資料庫函式。 |
| 4 |
insert Impala 的insert命令用於:
|
| 5 |
select select語句用於對特定資料集執行所需的操作。它指定要完成某些操作的資料集。您可以列印或儲存(在檔案中)select 語句的結果。 |
| 6 |
show Impala 的show語句用於顯示各種構造(例如表、資料庫和表)的元儲存。 |
| 7 |
use Impala 的use語句用於將當前上下文更改為所需的資料庫。 |