本文描述对 Impala 的创建数据库,创建表,写入数据,查询表等基本操作。
说明
Impala-shell 命令操作请参考“Impala-shell 工具”。
root@emr-4nw5w1f78f3xxx-master-1:~# impala-shell /opt/emr/2.0.0/impala-3.4.1/shell/impala-shell-3.4.1-RELEASE/ext-py2/bitarray-0.9.0-py2.7-linux-x86_64.egg/bitarray/_bitarray.py:3: UserWarning: Module backports was already imported from None, but /usr/lib/python2.7/dist-packages is being added to sys.path Starting Impala Shell without Kerberos authentication Opened TCP connection to emr-4nw5w1f78f3xxx-master-1:21000 Connected to emr-4nw5w1f78f3xxx-master-1:21000 Server version: impalad version 3.4.1-RELEASE RELEASE (build eb1ed66fa435a722fa8c6a7c58ff53edc10c572e) *********************************************************************************** Welcome to the Impala shell. (Impala Shell v3.4.1-RELEASE (eb1ed66) built on Fri Sep 16 15:03:38 CST 2022) Want to know what version of Impala you're connected to? Run the VERSION command to find out! *********************************************************************************** [emr-4nw5w1f78f3xxx-master-1:21000] default>
[emr-4nw5w1f78f3xxx-master-1:21000] default> create database first_db; Query: create database first_db +----------------------------+ | summary | +----------------------------+ | Database has been created. | +----------------------------+ Fetched 1 row(s) in 5.36s
[emr-4nw5w1f78f3xxx-master-1:21000] default> use first_db; Query: use first_db
[emr-4nw5w1f78f3xxx-master-1:21000] first_db> CREATE TABLE parquet_table ( id INT) STORED AS PARQUET; Query: CREATE TABLE parquet_table ( id INT) STORED AS PARQUET +-------------------------+ | summary | +-------------------------+ | Table has been created. | +-------------------------+ Fetched 1 row(s) in 5.26s
[emr-4nw5w1f78f3xxx-master-1:21000] first_db> insert into parquet_table values(1); Query: insert into parquet_table values(1) Query submitted at: 2022-10-17 16:52:34 (Coordinator: http://emr-4nw5w1f78f3xxx-core-1:25000) Query progress can be monitored at: http://emr-4nw5w1f78f3xxx-core-1:25000/query_plan?query_id=8549b1a1cd09d63d:f8d8828f00000000 Modified 1 row(s) in 15.70s
[emr-4nw5w1f78f3xxx-master-1:21000] first_db> select * from parquet_table; Query: select * from parquet_table Query submitted at: 2022-10-17 16:53:10 (Coordinator: http://emr-4nw5w1f78f3xxx-core-1:25000) Query progress can be monitored at: http://emr-4nw5w1f78f3xxx-core-1:25000/query_plan?query_id=5744559c2307a8b9:a411428400000000 +----+ | id | +----+ | 1 | +----+ Fetched 1 row(s) in 0.26s
[emr-4nw5w1f78f3xxx-master-1:21000] first_db> drop table parquet_table; Query: drop table parquet_table +-------------------------+ | summary | +-------------------------+ | Table has been dropped. | +-------------------------+ Fetched 1 row(s) in 5.23s