课程表

Impala 基础

Table 特定语句

Impala 子句

工具箱
速查手册

impala Shell

当前位置:免费教程 » 大数据/云 » Impala

在前面的章节中,我们已经看到了使用cloudera及其体系结构安装Impala。

  • Impala shell(命令提示符)
  • Hue (用户界面)
  • ODBC和JDBC(第三方库)

本章介绍如何启动Impala Shell和shell的各种选项。

Impala Shell命令参考

Impala shell的命令分为一般命令,查询特定选项以及表和数据库特定选项,如下所述。

通用命令

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

查询特定的选项

  • Set/unset
  • Profile
  • Explain

表和数据库特定选项

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

启动Impala Shell

打开cloudera终端,以超级用户身份登录,然后键入cloudera作为密码,如下所示。

  1. [cloudera@quickstart ~]$ su
  2. Password: cloudera
  3. [root@quickstart cloudera]#

通过键入以下命令启动Impala shell -

  1. [root@quickstart cloudera] # impala-shell
  2. Starting Impala Shell without Kerberos authentication
  3. Connected to quickstart.cloudera:21000
  4. Server version: impalad version 2.3.0-cdh5.5.0 RELEASE
  5. (build 0c891d79aa38f297d244855a32f1e17280e2129b)
  6. *********************************************************************
  7.  
  8. Welcome to the Impala shell. Copyright (c) 2015 Cloudera, Inc. All rights reserved.
  9. (Impala Shell v2.3.0-cdh5.5.0 (0c891d7) built on Mon Nov 9 12:18:12 PST 2015)
  10.  
  11. Want to know what version of Impala you're connected to? Run the VERSION command to
  12. find out!
  13. *********************************************************************
  14. [quickstart.cloudera:21000] >

Impala - 通用命令

Impala的通用命令解释如下 - 

help命令

Impala shell的help命令提供了Impala中可用的命令的列表 -

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

version命令

version命令为您提供Impala的当前版本,如下所示。

  1. [quickstart.cloudera:21000] > version;
  2. Shell version: Impala Shell v2.3.0-cdh5.5.0 (0c891d7) built on Mon Nov 9
  3. 12:18:12 PST 2015
  4.  
  5. Server version: impalad version 2.3.0-cdh5.5.0 RELEASE (build
  6. 0c891d79aa38f297d244855a32f1e17280e2129b)

history命令

Impala的history命令显示在shell中执行的最后10个命令。 以下是历史命令的示例。 这里我们执行了5个命令,即版本,帮助,显示,使用和历史。

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

quit/exit命令

您可以使用quit或exit命令从Impala shell中弹出,如下所示。

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

connect命令

connect命令用于连接到Impala的给定实例。 如果没有指定任何实例,则它将连接到默认端口21000,如下所示。

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

Impala查询特定选项

Impala的特定于查询的命令接受查询。 它们在下面解释 - 

说明

explain命令返回给定查询的执行计划。

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

简介

profile命令显示有关最近查询的低级信息。 此命令用于查询的诊断和性能调整。 以下是配置文件命令的示例。 在这种情况下,profile命令返回说明查询的低级信息。

  1. [quickstart.cloudera:21000] > profile;
  2.  
  3. Query Runtime Profile:
  4. Query (id=164b1294a1049189:a67598a6699e3ab6):
  5.  
  6. Summary:
  7. Session ID: e74927207cd752b5:65ca61e630ad3ad
  8. Session Type: BEESWAX
  9. Start Time: 2016-04-17 23:49:26.08148000 End Time: 2016-04-17 23:49:26.2404000
  10. Query Type: EXPLAIN
  11. Query State: FINISHED
  12. Query Status: OK
  13. Impala Version: impalad version 2.3.0-cdh5.5.0 RELEASE (build 0c891d77280e2129b)
  14. User: cloudera
  15. Connected User: cloudera
  16. Delegated User:
  17. Network Address:10.0.2.15:43870
  18. Default Db: my_db
  19. Sql Statement: explain select * from sample
  20. Coordinator: quickstart.cloudera:22000
  21. : 0ns
  22. Query Timeline: 167.304ms
  23. - Start execution: 41.292us (41.292us) - Planning finished: 56.42ms (56.386ms)
  24. - Rows available: 58.247ms (1.819ms)
  25. - First row fetched: 160.72ms (101.824ms)
  26. - Unregister query: 166.325ms (6.253ms)
  27. ImpalaServer:
  28. - ClientFetchWaitTimer: 107.969ms
  29. - RowMaterializationTimer: 0ns

表和数据库特定选项

下表列出了Impala中的表和数据特定选项。

Sr.No指挥解释
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语句用于将当前上下文更改为所需的数据库。

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号