impala 不可轻易更换列类型

1.建表

[slave01:21000] > use tmp;
Query: use tmp
[slave01:21000] > create table ml_2(a int ,b double,c varchar(10));
Query: create table ml_2(a int ,b double,c varchar(10))

Fetched 0 row(s) in 0.17s
[slave01:21000] > show create table ml_2;
Query: show create table ml_2
+---------------------------------------------------------------+
| result                                                        |
+---------------------------------------------------------------+
| CREATE TABLE tmp.ml_2 (                                       |
|   a INT,                                                      |
|   b DOUBLE,                                                   |
|   c VARCHAR(10)                                               |
| )                                                             |
| STORED AS TEXTFILE                                            |
| LOCATION 'hdfs://master:8020/user/hive/warehouse/tmp.db/ml_2' |
|                                                               |
+---------------------------------------------------------------+
Fetched 1 row(s) in 4.88s

2. 插入一条数据

[slave01:21000] > insert into ml_2(a,b,c) values(22,22.44,cast('99' as varchar(10)));
Query: insert into ml_2(a,b,c) values(22,22.44,cast('99' as varchar(10)))
Query submitted at: 2017-10-11 15:11:53 (Coordinator: http://slave01:25000)
Query progress can be monitored at: http://slave01:25000/query_plan?query_id=854afd0054173c92:1df06c4e00000000
Modified 1 row(s) in 0.22s
[slave01:21000] > select * from ml_2;
Query: select * from ml_2
Query submitted at: 2017-10-11 15:12:03 (Coordinator: http://slave01:25000)
Query progress can be monitored at: http://slave01:25000/query_plan?query_id=73446eb417d3d311:7720be2d00000000
+----+-------+----+
| a  | b     | c  |
+----+-------+----+
| 22 | 22.44 | 99 |
+----+-------+----+
Fetched 1 row(s) in 0.34s

3.更换类型

[slave01:21000] > alter table ml_2 change b b_int int;
Query: alter table ml_2 change b b_int int

Fetched 0 row(s) in 0.42s
[slave01:21000] > select * from ml_2;
Query: select * from ml_2
Query submitted at: 2017-10-11 15:12:43 (Coordinator: http://slave01:25000)
Query progress can be monitored at: http://slave01:25000/query_plan?query_id=47c3066e47d4e1:85ce76b100000000
+----+-------+----+
| a  | b_int | c  |
+----+-------+----+
| 22 | NULL  | 99 |
+----+-------+----+
WARNINGS: Error converting column: 1 to INT
Error parsing row: file: hdfs://master:8020/user/hive/warehouse/tmp.db/ml_2/854afd0054173c92-1df06c4e00000000_349445573_data.0., before offset: 12

Fetched 1 row(s) in 0.14s

4. 修改回来,也可以正常使用。

[slave01:21000] > alter table ml_2 change  b_int b double;
Query: alter table ml_2 change  b_int b double

Fetched 0 row(s) in 0.34s
[slave01:21000] > select * from ml_2;
Query: select * from ml_2
Query submitted at: 2017-10-11 15:13:09 (Coordinator: http://slave01:25000)
Query progress can be monitored at: http://slave01:25000/query_plan?query_id=7b403624be3e00a1:649c943b00000000
+----+-------+----+
| a  | b     | c  |
+----+-------+----+
| 22 | 22.44 | 99 |
+----+-------+----+
Fetched 1 row(s) in 0.24s
[slave01:21000] > 


你可能感兴趣的:(hadoop)