Friday, March 2, 2018

Hive rename table column on Avro data format

0: jdbc:hive2://cdh-vm.dbaglobe.com:10000> create table t1 (id1 int) stored as avro;

0: jdbc:hive2://cdh-vm.dbaglobe.com:10000> insert into t1 values(1);

0: jdbc:hive2://cdh-vm.dbaglobe.com:10000> insert into t1 values(2);

0: jdbc:hive2://cdh-vm.dbaglobe.com:10000> alter table t1 change id1 id2 int;

0: jdbc:hive2://cdh-vm.dbaglobe.com:10000> insert into t1 values(3);

0: jdbc:hive2://cdh-vm.dbaglobe.com:10000> select * from t1;
+---------+--+
| t1.id2  |
+---------+--+
| NULL    |
| NULL    |
| 3       |
+---------+--+
3 rows selected (0.135 seconds)

[donghua@cdh-vm ~]$ hdfs dfs -cat /user/hive/warehouse/t1/000000_0
Objavro.schema?{"type":"record","name":"t1","namespace":"default","fields":[{"name":"id1","type":["null","int"],"default":null}]}p??&T??z???Ӌ??&T??z???Ӌ

[donghua@cdh-vm ~]$ hdfs dfs -cat /user/hive/warehouse/t1/000000_0_copy_1
Objavro.schema?{"type":"record","name":"t1","namespace":"default","fields":[{"name":"id1","type":["null","int"],"default":null}]}?0??Qs>?4?????0??Qs>?4????

[donghua@cdh-vm ~]$ hdfs dfs -cat /user/hive/warehouse/t1/000000_0_copy_2
Objavro.schema?{"type":"record","name":"t1","namespace":"default","fields":[{"name":"id2","type":["null","int"],"default":null}]}>?>?)x?Dv&?I??1>?>?)x?Dv&?I??1

No comments:

Post a Comment