[英]hive column name alter without loosing data in portitioned avro table
i have a avro hive table partitioned by date.我有一个按日期分区的 avro hive 表。
acct_no <string> acct_cd <int> date <date>
acct01 01 2022-10-31
acct02 02 2022-10-31
acct03 03 2022-10-31
i want to rename acct_cd to account_code我想将 acct_cd 重命名为 account_code
i used command我用命令
alter table <table_name> change acct_cd account_code int;
it changed the table attribute but data lost:它更改了表属性但数据丢失:
acct_no <string> account_code <int> date <date>
acct01 null 2022-10-31
acct02 null 2022-10-31
acct03 null 2022-10-31
How to avoid losing data and change the column name?如何避免丢失数据和更改列名?
As per hive, hive , change
a column name just changes hive metadata, underlying data/structure remains as is.根据hive、hive ,
change
列名只会更改 hive 元数据,底层数据/结构保持原样。 Which means, you have to take care of the data after alter.这意味着,您必须在更改后处理数据。
You have two options -你有两个选择 -
insert overwrite table
command to fillup original table from backup table.insert overwrite table
命令从备份表中填充原始表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.