重命名配置单元 ORC table 中的列名称导致新列中出现 NULL 值

Renaming Column names in hive ORC table is resulting in NULL values in the New column

我正在尝试使用 alter 命令重命名配置单元 (ORC table) table 中的列名。列正在重命名,但数据正在修改为 Null 值。

示例:

select city from p_details;

city

Santa Fe Springs
Jiangmen

**alter table p_details change city city_name string;**

select city_name from p_details;

city_name

NULL
NULL

根据Hive manual:“列更改命令只会修改 Hive 的元数据,不会修改数据。用户应确保 table/partition 的实际数据布局符合元数据定义。”,这意味着如果它是 orc 或 parquet table,则列更改不会更改任何基础数据。 尝试执行 msck repair table <table_name>,但可能无济于事。

您始终可以使用重命名的列创建新的 table。